电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

数据库实验答案分析总结VIP免费

数据库实验答案分析总结_第1页
1/8
数据库实验答案分析总结_第2页
2/8
数据库实验答案分析总结_第3页
3/8
实验三用SQL语句完成以下的要求(键表及插入数据的SQL语句见下面):createtablestudent(Snochar(5)primarykey,Snamechar(10),Ssexchar(2),Sageint,Sdeptchar(2));createtableCourse(Cnochar(1)primarykey,Cnamechar(20),Cpnochar(1),Ccreditint);createtableSC(Snochar(5),Cnochar(1),Gradeint,primarykey(sno,cno));insertintostudentvalues('95001','李勇','男',20,'CS');insertintostudentvalues('95002','刘晨','女',21,'IS');insertintostudentvalues('95003','王敏','女',18,'MA');insertintostudentvalues('95004','张力','男',19,'IS');insertintoCoursevalues('1','数据库','5',4);insertintoCoursevalues('2','数学',NULL,2);insertintoCoursevalues('3','信息系统','1',4);insertintoCoursevalues('4','操作系统','6',3);insertintoCoursevalues('5','数据结构','7',4);insertintoCoursevalues('6','数据处理',NULL,2);insertintoCoursevalues('7','PASCAL语言','6',4);insertintoSCvalues('95001','1',92);insertintoSCvalues('95001','2',85);insertintoSCvalues('95001','3',88);insertintoSCvalues('95002','2',90);insertintoSCvalues('95003','3',85);1.查询信息系(IS)的所有学生信息select*fromStudentwhereSdept='IS';2.查询选修了“数学”课的所有学生名单select*fromStudent,Course,SCwhereStudent.Sno=SC.SnoAndCourse.Cno=SC.CnoAndCourse.Cname='数学';3.查询至少选修了一门其直接先行课为5号课程的学生的姓名。selectStudent.SnamefromStudent,Course,SCwhereStudent.Sno=SC.SnoAndCourse.Cno=SC.CnoAndCourse.Cpno='5'4.查询全体学生的姓名和出生年份。selectsname,2013-Student.SagefromStudent5.查询所有姓王的学生。select*fromStudentwhereSnamelike'王%';6.查询选修了3号课程的学生姓名及成绩,并按成绩降序排序。selectStudent.Sname,SC.GradefromStudent,Course,SCwhereStudent.Sno=SC.SnoandCourse.Cno=Sc.cnoandcourse.cno='3'orderbysc.gradedesc7.查询全体学生情况,查询结果按所在系的系号升序排列,同一系中的学生按年龄降序排列。select*fromstudentorderbysdept,sagedesc8.计算2号课程的平均成绩。selectAVG(grade)fromSCwherecno='2';9.查询选修了2号课程的学生的最高成绩。selectMAX(grade)fromSCwherecno='2';10.求各个课程号及相应的选课人数。selectcno,COUNT(distinctsno)fromSCgroupbycno11.查询至少选修了3门课程以上的学生序号。selectsnofromSCgroupbysnohavingCOUNT(*)>=3;12.查询“数据库”的间接先行课。selectsecond.cpnofromCourseasfirst,Courseassecondwherefirst.cpno=second.CnoAndfirst.Cname='数据库';13.查询其他系中比信息系某一学生年龄小的学生的姓名和年龄。selectdistinctfirst.sname,first.sagefromStudentasfirst,Studentassecondwherefirst.SageAVG(second.Grade);16.查询至少选修了1号课程和3号课程的学生学号。(selectsnofromSCwhereCno='1')intersect(selectsnofromSCwhereCno='3');17.查询只选修了1号课程和3号课程的学生学号。selectsnofromSCwhereCno='1'andSnoin(selectSnofromSCwhereCno='2'andSnoin(selectSnofromSCgroupbySnohavingCOUNT(sno)=2));18.查询没有选修1号课程的学生姓名。selectsnamefromstudent,scwheresc.snonotin(selectsnofromscwherecno='1')andsc.sno=student.sno19.查询选修了全部课程的学生姓名。selectsnamefromstudentwherestudent.snoin(selectsnofromscasonewherenotexists(select*fromSCastwowherenotexists(select*fromSCasthreewherethree.Sno=one.Snoandthree.Cno=two.Cno)));20.查询至少选修了95002所选修的全部课程的学生学号。selectdistinctsnofromscasonewherenotexists(select*...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

数据库实验答案分析总结

您可能关注的文档

书海行舟+ 关注
实名认证
内容提供者

热爱教学事业,对互联网知识分享很感兴趣

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部