1.create view test6_01 as select sid,name,dname from pub.student where age<20 and dname='物理學院'order by sid
select * from test6_01
2.create view test6_02(sid,name,sum_score)
as (select pub.student.sid,name,sum(score)
from pub.student,pub.student_course
where pub.student.sid=pub.student_course.sid
and dname='軟體學院'
and class=2009
group by pub.student.sid,name)
select * from test6_02
3.create view test6_03 as(
select pub.student.sid,pub.student.name,score
from pub.student,pub.student_course,pub.course
where pub.student.sid=pub.student_course.sid
and pub.student_course.cid=pub.course.cid
and class=2010
and dname='電腦科學與技術學院'
and pub.course.name='作業系統')
select * fromm test6_03
4.create view test6_04 as
(select pub.student.sid,pub.student.name
from pub.student_course,pub.student,pub.course
where pub.student_course.sid=pub.student.sid
and pub.student_course.cid=pub.course.cid
and pub.course.name ='資料庫系統'
and score>90)
select * from test6_04
5.create view test6_05 as
(select pub.student.sid,pub.student_course.cid,pub.course.name,score
from pub.student,pub.student_course,pub.course
where pub.student_course.sid=pub.student.sid
and pub.student_course.cid=pub.course.cid
and pub.student.name='李龍'
)6.create view test6_06 as(
select pub.student.sid,name
from pub.student
where not exists(
(select cid
from pub.course)
minus(
select cid
from pub.student_course
where pub.student_course.sid=pub.student.sid)))
7.create view test6_07 as
(select sid,name
from pub.student
where sid in(
select sid
from pub.student_course
where score>=60)
and not exists((
select cid
from pub.course)
minus(select cid
from pub.student_course)))
create view test6_07 as
(select sid,name
from test6_06 where sid in
(select distinct sid
from pub.student_course
where sid in(select sid
from test6_06) and score>60))//不知道前兩個尤其是第二個為什麼不行,第二個有15行資料錯誤,下面的才是正確答案
create view test6_07 as
select * from test6_06 where sid not in (
select distinct sid from pub.student_course where sid in(select sid from test6_06) and score<60)
8.create view test6_08 as
(select cid,name
from pub.course
where fcid in(
select cid
from pub.course
where credit=2))
9.create view test6_09(sid,name,sum_credit)as
(select pub.student.sid,pub.student.name,sum(credit)
from pub.student,pub.student_course,pub.course
where pub.student_course.sid=pub.student.sid
and pub.student_course.cid=pub.course.cid
and class=2010
and dname='化學與化工學院'
and score>=60
group by pub.student.sid,pub.student.name)
10.create view test6_10 as
(select cid,name
from pub.course
where fcid in(select cid
from pub.course
where fcid is not null))
山東大學資料庫系統實驗三
宣告 所有sql語句均在實驗平台驗證通過,實驗細節可能隨時間推移老師會進行修改。在此僅提供解答思路,畢竟我的方法肯定不是最優,而且實驗平台有查重功能,不要一昧的複製哦!1.刪除表中的學號不全是數字的那些錯誤資料,學號應該是數字組成,不能夠包含字母空格等非數字字元。create table test3...
山東大學資料庫系統實驗九
宣告 所有sql語句均在實驗平台驗證通過,實驗細節可能隨時間推移老師會進行修改。在此僅提供解答思路,畢竟我的方法肯定不是最優,而且實驗平台有查重功能,不要一昧的複製哦!建立表test9 01,表的結構同pub.student 11 1一樣。為test9 01的sid建立唯一不重複索引。將pub使用者...
山東大學《資料庫系統》實驗八
提交 commit 和回滾 rollback 實體授權 對比有無索引情況下資料檢索速度,學會如何能夠使用索引,掌握如何查詢是否使用索引了。啟動兩個不同瀏覽器,主賬號 userid 在 firefox 中登入 備用賬號 userbid 在另外乙個瀏覽器登入,或者主賬號在主平台登入,備用賬號在備平台登入...