山東大學軟體學院2017-18學年資料庫實驗五、六、七、八
注:所有實驗均為自己思考所答,非轉載抄襲,並全部通過實驗系統檢測。希望學弟學妹自主思考,答案不唯一可能有些效率不高,僅供參考。
-
實驗五
實驗步驟:(不要求羅列完整原始碼) create table test5_00 as select * from pub.TEACHER grant all on test5_00 to user201600301315 update test5_00 set age = 88 select * from test5_00 Commit Rollback update test5_00 set age = age + 1 Rollback Commit update test5_00 set age = age + 2 Commit select * from test5_00 Rollback select * from userb201600301315.test5_00 update test5_00 set age = age - 2 update test5_00 set age = age - 2 select * from test5_00 select * from userb201600301315.test5_00 Commit select * from userb201600301315.test5_00 Rollback update userb201600301315.test5_00 set age = age – 10 Select * from test5_00 create table test5_01 as select * from test5_00 Rollback select * from userb201600301315.test5_00 select * from userb201600301315.test5_00 Rollback select * from userb201600301315.test5_00
結果為:88 90 90 86 90 90 86 86 76 86 |
-
實驗六
實驗步驟:(不要求羅列完整原始碼)
create view test6_01 as select sid,name,dname from pub.STUDENT where age<20 and dname='物理學院' order by sid
create view test6_02 as select pub.STUDENT.SID sid,pub.STUDENT.NAME name,sum(score) sum_score from pub.STUDENT,pub.STUDENT_COURSE where pub.STUDENT.SID=pub.STUDENT_COURSE.SID and pub.STUDENT.CLASS=2009 and pub.STUDENT.DNAME='軟體學院' group by pub.STUDENT.SID,pub.STUDENT.NAME
create view test6_03 as select pub.STUDENT.SID sid,pub.STUDENT.NAME name,pub.STUDENT_COURSE.SCORE score from pub.STUDENT,pub.STUDENT_COURSE,pub.COURSE where pub.STUDENT_COURSE.CID=pub.COURSE.CID and pub.STUDENT.SID=pub.STUDENT_COURSE.SID and pub.STUDENT.CLASS=2010 and pub.STUDENT.DNAME='電腦科學與技術學院' and pub.COURSE.NAME = '作業系統'
create view test6_04 as select pub.STUDENT.SID sid,pub.STUDENT.NAME name from pub.STUDENT,pub.STUDENT_COURSE,pub.COURSE where pub.STUDENT_COURSE.CID=pub.COURSE.CID and pub.STUDENT.SID=pub.STUDENT_COURSE.SID and pub.COURSE.NAME = '資料庫系統' and pub.STUDENT_COURSE.SCORE>90
create view test6_05 as select pub.STUDENT.SID sid,pub.STUDENT_COURSE.CID cid,pub.COURSE.NAME,pub.STUDENT_COURSE.SCORE from pub.STUDENT,pub.STUDENT_COURSE,pub.COURSE where pub.STUDENT_COURSE.CID=pub.COURSE.CID and pub.STUDENT.SID=pub.STUDENT_COURSE.SID and pub.STUDENT.NAME='李龍'
create or replace view test6_06 as select a.SID,a.NAME from pub.STUDENT a where not exists ((select cid from pub.COURSE) minus (select cid from pub.STUDENT natural join pub.STUDENT_COURSE where a.sid = sid))
create or replace view test6_07 as select a.SID,a.NAME from pub.STUDENT a where not exists( (select cid from pub.COURSE) minus (select cid from pub.STUDENT natural join pub.STUDENT_COURSE where a.sid = sid and score>=60))
create or replace view test6_08 as select A.cid, A.NAME from pub.COURSE A, pub.COURSE B where A.FCID = B.CID and B.CREDIT = 2
注:學分為成績大於等於60才算
create or replace view test6_09 as select pub.STUDENT.SID sid,pub.STUDENT.NAME name,sum(credit) sum_credit 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 pub.STUDENT.CLASS=2010 and pub.STUDENT.DNAME='化學與化工學院' and pub.STUDENT_COURSE.SCORE>=60 group by pub.STUDENT.SID,pub.STUDENT.NAME
create or replace view test6_10 as select A.CID,A.NAME from pub.COURSE A,pub.COURSE B,pub.COURSE C where A.FCID = B.CID and B.FCID = C.CID
|
-
實驗七
實驗步驟:(不要求羅列完整原始碼)
create table test7_01 as select First_name, (count(*)) frequency from (select (substr(name,2)) First_name from pub.STUDENT) group by First_name
2.統計名字每個字的使用頻率
create table test7_02 as select letter,(count(*)) frequency from ((select (substr(name,2,1)) letter from pub.STUDENT) union all (select (substr(name,3,1)) letter from pub.STUDENT where substr(name,3,1) is not NULL)) group by letter
3.統計學院班級學分達標情況統計表1
create table test7_03 as select * from (select dname, class, (count(*)) P_count1 from (select S.sid, S.DNAME, S.CLASS, sum_credit from pub.STUDENT S, (select sid, (sum(credit)) sum_credit from pub.STUDENT_COURSE SC, pub.COURSE C where SC.CID = C.CID and SC.SCORE >= 60 and dname is not NULL group by sid) B where S.SID = B.SID) where sum_credit > = 10 and dname is not NULL group by dname, class)
natural full outer join
(select dname, class, (count(*)) P_count2 from (select S.sid, S.DNAME, S.CLASS, sum_credit from pub.STUDENT S, (select sid, (sum(credit)) sum_credit from pub.STUDENT_COURSE SC, pub.COURSE C where SC.CID = C.CID and SC.SCORE >= 60 and dname is not NULL group by sid) B where S.SID = B.SID) where sum_credit < 10 and dname is not NULL group by dname, class)
natural full outer join
(select * from (select dname, class, (count(*)) P_count from pub.STUDENT where dname is not NULL group by dname, class) sum_count)
4.統計學院班級學分達標情況統計表2
create table test7_04 as select * from (select dname, class, (count(*)) P_count1 from (select A.sid, A.DNAME, A.CLASS, sum_credit from pub.STUDENT A, (select sid, (sum(credit)) sum_credit from pub.STUDENT_COURSE S, pub.COURSE K where S.CID = K.CID and S.SCORE >= 60 group by sid) B where A.SID = B.SID and A.DNAME is not NULL) where (sum_credit > = 10) or (sum_credit > = 8 and class <= 2008) group by dname, class) natural full outer join (select dname, class, (count(*)) P_count2 from (select A.sid, A.DNAME, A.CLASS, sum_credit from pub.STUDENT A, (select sid, (sum(credit)) sum_credit from pub.STUDENT_COURSE S, pub.COURSE K where S.CID = K.CID and S.SCORE >= 60 group by sid) B where A.SID = B.SID) where sum_credit < 10 and dname is not NULL group by dname, class) natural full outer join (select * from (select dname, class, (count(*)) P_count from pub.STUDENT where dname is not NULL group by dname, class) sum_count) |
-
實驗八
實驗步驟:(不要求羅列完整原始碼)
create table test8_01 as select * from (select dname, (round(avg(s1),0)) Avg_ds_score from (select pub.STUDENT.SID, max(score) s1 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 pub.COURSE.NAME = '資料結構' group by pub.STUDENT.SID) A, pub.STUDENT B where A.SID = B.SID and dname is not NULL group by dname)
natural full outer join
(select dname, (round(avg(s2),0)) Avg_os_score from (select pub.STUDENT.SID, max(score) s2 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 pub.COURSE.NAME = '作業系統' group by pub.STUDENT.SID) A, pub.STUDENT B where A.SID = B.SID and dname is not NULL group by dname)
create table test8_02 as select A.SID, name, dname, ds_score, os_score from (select pub.STUDENT.SID, max(score) ds_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 pub.COURSE.NAME = '資料結構' group by pub.STUDENT.SID) A,
(select pub.STUDENT.SID, max(score) os_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 pub.COURSE.NAME = '作業系統' group by pub.STUDENT.SID) B,
pub.STUDENT C
where A.SID = B.SID and B.SID = C.SID and dname = '電腦科學與技術學院'
create table test8_03 as select sid, name, dname, ds_score, os_score from (select * from (select pub.STUDENT.SID, max(score) ds_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 pub.COURSE.NAME = '資料結構' group by pub.STUDENT.SID)
natural full outer join
(select pub.STUDENT.SID, max(score) os_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 pub.COURSE.NAME = '作業系統' group by pub.STUDENT.SID) )
natural join pub.STUDENT where dname = '電腦科學與技術學院'
create table test8_04 as select sid, name, dname, ds_score, os_score from (select * from (select pub.STUDENT.SID, max(score) ds_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 pub.COURSE.NAME = '資料結構' group by pub.STUDENT.SID)
natural full outer join
(select pub.STUDENT.SID, max(score) os_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 pub.COURSE.NAME = '作業系統' group by pub.STUDENT.SID) ) natural right outer join pub.STUDENT where dname = '電腦科學與技術學院'
|
相關文章
- 山東大學軟體學院2017-18學年大二資料結構實驗一、二、三、四資料結構
- 學好Oracle資料庫的六條經驗Oracle資料庫
- DC學院學習筆記(六):資料庫和SQL語言簡述筆記資料庫SQL
- 資料庫實驗八 資料庫程式設計資料庫程式設計
- 2021年春季學期 計算機學院《軟體構造》課程 Lab 1實驗報告計算機
- 資料庫實驗五 資料庫的安全性資料庫
- 百度前端學院-基礎學院-第七天到第八天前端
- Redis學習筆記(七) 資料庫Redis筆記資料庫
- 軟體測試之資料庫系列六資料庫
- InnoDB學習(六)之資料庫鎖資料庫
- 軟體測試之資料庫系列五資料庫
- 資料庫學習(五)子查詢資料庫
- 優思學院|六西格瑪實驗設計(DOE)咖啡沖泡案例
- 系統學習大資料需要學習哪些內容,五年大資料工程師經驗分享大資料工程師
- VMware 加入 OSSI 開源軟體學院
- 浙大軟體學院的宣傳照
- 安卓第七夜 雅典學院安卓
- MYSQL學習與實驗(八)——儲存過程實驗MySql儲存過程
- 資料庫學習(六)聯合查詢union資料庫
- 飛機的 PHP 學習筆記八:資料庫PHP筆記資料庫
- 從AdventureWorks學習資料庫建模——實體分析資料庫
- MYSQL學習與實驗(一)——資料庫定義與操作MySql資料庫
- 菜鳥學資料庫(五)——MySQL必備命令資料庫MySql
- 2021 年最佳資料科學工具和軟體 - datamation資料科學
- 軟體測試學習 ——五種軟體測試模型模型
- 百度前端學院任務動態資料繫結(五)前端
- 軟體測試之資料庫測試技術系列七資料庫
- DC學院學習筆記(九):利用Python進行資料庫操作筆記Python資料庫
- Python資料科學(七) 資料清理(Ⅱ)Python資料科學
- 深圳軟體測試學習:【資料庫】-【oracle】-連線查詢資料庫Oracle
- Oracle資料庫學習應用:經驗分享Oracle資料庫
- 醫院核心資料庫一體化建設實踐資料庫
- Python資料科學(六) 資料清理(Ⅰ)Python資料科學
- Java軟體開發者,如何學習大資料?Java大資料
- 重學資料結構(七、圖)資料結構
- 【恩墨學院】從資料庫建立深入學習Oracle技術:那些年 mkplug 偷偷執行的Plugin操作資料庫OraclePlugin
- swoft 學習筆記之資料庫配置與實體定筆記資料庫
- 墨者學院-SQL手工注入漏洞測試(MySQL資料庫)MySql資料庫