SQL_实验1.4 清华大学出版社

/*1.*/
create view cs
as select no,sid,cid,score
from choices
where score>=60;

/*another*/
create view cs
(no, sid ,cid ,score)
as select choices.no, choices.sid, choices.cid, choices.score
from choices
where choices.score>=60
with check option;
/*another*/
create view cs
as select no, sid, cid, score
from choices
where score >= 60
with check option;

/*2.*/
create view sct
(sname,cname,tname)
as select students.sname,courses.cname,teachers.tname
from choices, students, courses, teachers
where choices.tid=teachers.tid and choices.cid = courses.cid and choices.sid = students.sid;

/*3.*/
create view scc
(sname, cname, score)
as select students.sname, courses.cname, choices.score + 5
from choices, students, courses
where choices.cid = courses.cid and choices.sid = students.sid;

/*4.*/
create view s_g(sid,savg)
	as
		select sid,avg(score)
		from choices
		group by sid;

/*5.*/
create view s_c_s(sid ,ccount,savg)
as 
select sid,count(cs.cid), avg(score)
from cs
group by cs.sid;

/*6.find the sname who choice software engineering*/
select sname
from sct
where cname = ‘software engineering‘;

/*7.add (600000000,823069829,10010,59)*/
insert
into cs
values(‘600000000‘,‘823069829‘,‘10010‘,‘59‘);
/*此处错误执行了delete - =少了4个元组。。)*/

/*8.*/
update cs
set score = score + 5
where cid = ‘10010‘ and score < 95;

/*9.delete sid=‘823069829‘*/
delete cs
where sid = ‘823069829‘;

/*10.drop sct,cs)*/
drop view sct
drop view cs;

SQL_实验1.4 清华大学出版社,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。