数据库考试题目和答案(2)

2018-11-20 19:13

(select cnum from sc where grade is not null

group by cnum having avg(grade)>80);

select * from faculty; 在SC中删除尚无成绩的选课元组; delete from sc where grade is null

20将选修’liu’老师课程的女同学选课元组全部删除; delete from sc where snum in

(select snum from s where sex='女')

and cnum in (select cnum from c where teacher='liu')

21将’MATHS’课不及格的成绩全改为60分; update sc set grade=60 where grade<60

and cnum in(select cnum from c where cname='maths')

22将低于所有课程总平均成绩的女同学成绩提高5%; update sc set grade=grade*(1+0.05)

where grade<(select avg(grade) from sc where grade is not null) and snum in(select snum from s where sex='女')

23在表SC中修改’C4’课程的成绩,若成绩小于等于70分时提高5%,若成绩大于70分时提高4%;

update sc set grade=grade*(1+0.05) where cnum='c4' and grade<70; update sc set grade=grade*(1+0.04) where cnum='c4' and grade>70; 24在表SC中,当某个成绩低于全部课程的平均成绩时,提高5%; update sc set grade=grade*(1+0.05)

where grade<(select avg(grade) from sc where grade is not null)

25求男同学每一年龄的人数;

select age,count(age) from s where sex='男' group by age 26求女同学的人数和平均年龄及平均成绩;

select count( sex) num,avg(age) avg_age,avg(grade) avg_grade from s,sc where sc.snum=s.snum and grade is not null and sex='女' group by sex 27检索开设两门以上课程的教师姓名;

select teacher from c group by teacher having count(*)>2

28检索未选修’wang’老师所授全部课程的学生学号; select snum from s where snum not in

(select snum from sc where cnum in

(select cnum from c where teacher='wang'))

29统计选修每一门课程的男女学生人数和平均成绩,要求显示

(CNUM,CNAME,TEACHER,SEX,NUM,AVG_GRADE),其中NUM和AVG_GRADE为人数和平均成绩。 select

sc.cnum,c.cname,c.teacher,s.sex,count(*)

num,avg(grade)

avg_grade from s,c,sc

where sc.snum=s.snum and sc.cnum=c.cnum and grade is not null group by s.sex,sc.cnum,c.cname,c.teacher

4、 对于图书发行数据库(B_PUBLISH)构造4个基本表: STORE(SNO,SNAME,ADDRESS) ;( 注:STORE为“书店”) LIBRARY(LNO,LNAME,CITY,TEL);( 注:LIBRARY为“图书馆”) BOOK(BNO,BNAME,PRICE) ;( 注:BOOK为“图书”)

LBS(LNO,BNO,SNO,QTY); ( 注:LBS为“馆藏”;QTY为“数量”)

(1)创建图书发行数据库:书店信息表、图书馆信息表、图书信息表、馆藏信息表;

(2)为每个基表添加多条记录(自己添加,所添加的数据要能够满足以下各题的查询要求);

(3)查找’L1’从书店’S1’购买的图书书号及其册数;

Select bno,qty from lbs where sno=’S1’ and lno=’L1’; (4)取出馆址在’Shanghai’的馆名及电话号码;

Select lname,tel from library where city=’shanghai’; (5)取出’S3’发行的图书书名和数量;

Select distinct bname,qty from book,lbs where book.bno=lbs.bno and sno=’S3’;

(6)取出已发行图书中最贵和最便宜的那种书的书名和定价;

Select bno,price from book where price=(select max(price) from book)

or price=(select min(price) from book);

(7)查找购买图书’B4’最多的图书馆馆名;

Select lname from library where lno in(select lno from lbs where bno=’B4’

and qty=(select max(qty) from lbs));

(8)取出’L4’ 收藏图书的书名; Select bname from book where bno in

(select bno from lbs where lno=’L4’); (9)取出收藏图书’情报检索语言’的馆名; Select lname from library where lno in

(select lno from lbs where bno in

(select bno from book where bname=’情报检索语言’));

(10)将’B5’的单价更改为32.50元;

Update book set price=32.50 where bno=’B5’; (11)删去’B2’及其相关的馆藏记录; Delete from book where bno=’B2’; Delete from lbs where bno=’B2’;

(12)将(‘B6’,’人工智能原理’,42.00)登入关系BOOK。 Insert into book values(‘B6’,’人工智能原理’,42.00); 3、实验结束时提交《课程设计报告》,内容包含: (1)列出每个基表的结构及记录构成;

(2)对第2大题的每小题,均要求用关系代数表示; (3)用SQL Server 2000语句完成每一题; (4)每题的结果。


数据库考试题目和答案(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2015年新版-福建省房屋建筑工程竣工验收报告-福建省住房和城乡建

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: