实验步骤:(不要求罗列完整源代码) 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 = '计算机科学与技术学院'
|