第3章课堂综合练习题答案.ppt

An Introduction to Database System 综合练习答案 11、检索姓名以L打头的所有学生的姓名和年龄 S(sno,sname,sex,age) SC(sno,cno,grade) C(cno,cname,teacher) Select sname,age from S where sname like ‘L%’ 涉及到的表:S An Introduction to Database System 综合练习答案 12、求年龄大于所有女同学年龄的男学生姓名和年龄 S(sno,sname,sex,age) SC(sno,cno,grade) C(cno,cname,teacher) Select sname,age from S where sex=‘M’ and ageall (select age from S where sex=‘F’) 涉及到的表:S 方法一:all An Introduction to Database System 综合练习答案 12、求年龄大于所有女同学年龄的男学生姓名和年龄 S(sno,sname,sex,age) SC(sno,cno,grade) C(cno,cname,teacher) Select sname,age from S where sex=‘M’ and age (select max(age) from S where sex=‘F’) 涉及到的表:S 方法二:max An Introduction to Database System 综合练习答案 13、往关系C中插一个课程元组(’C8’,’VC++’,’BAO’) S(sno,sname,sex,age) SC(sno,cno,grade) C(cno,cname,teacher) Insert into C values(‘C8’,’VC++’,’BAO’) An Introduction to Database System 综合练习答案 14、把选修LIU老师课程的女同学选课元组全部删去 S(sno,sname,sex,age) SC(sno,cno,grade) C(cno,cname,teacher) Delete from SC where sno in (select sno from S where sex=‘F’) and cno in (select cno from C where teacher=‘LIU’) An Introduction to Database System 综合练习答案 15、把低于所有课程总平均成绩的男同学成绩提高5% S(sno,sname,sex,age) SC(sno,cno,grade) C(cno,cname,teacher) Update SC set grade=grade*1.05 where sno in (select sno from S where sex=‘F’) and grade (select age(grade) from SC) An Introduction to Database System 第三章 综合练习 设有三个关系: S(sno,sname,sex,age) SC(sno,cno,grade) C(cno,cname,teacher) 试用SQL语句表示下列查询语句 3、查询学号为S3学生所学课程的课程名与任课教师名 4、查询至少选修LIU老师所授课程中一门课程的女学生姓名 5、查询WANG同学不学的课程的课程号 6、查询至少选修两门课的学生学号 7、查询全部学生都选修的课程的课程号与课程名 8、查询选修课程包含LIU老师所授全部课程的学生学号。 1、查询LIU老师所授课程的课程号和课程名 2、查询年龄大于23岁的男学生的学号和姓名 An Introduction to Database System 第三章 综合练习 设有三个关系: S(sno,sname,sex,age) SC(sno,cno,grad

文档评论(0)

1亿VIP精品文档

相关文档