SQL练习题参考答案.doc

SQL练习题参考答案.doc

ID:57631791

大小:58.50 KB

页数:5页

时间:2020-08-29

SQL练习题参考答案.doc_第1页
SQL练习题参考答案.doc_第2页
SQL练习题参考答案.doc_第3页
SQL练习题参考答案.doc_第4页
SQL练习题参考答案.doc_第5页
资源描述:

《SQL练习题参考答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、针对以上四个表,用SQL语言完成以下各项操作:①给学生表增加一属性Nation(民族),数据类型为Varchar(20);AltertablestudentaddNationVarchar(20);②删除学生表中新增的属性Nation;AltertablestudentdropcolumnNation;③向成绩表中插入记录(”2001110”,”3”,80);insertintoGradevalues('2001103','3',80);④修改学号为”2001103”的学生的成绩为70分;updateGrades

2、etGmark=70whereSno='2001103';⑤删除学号为”2001110”的学生的成绩记录;deleteGradewhereSno='2001110';⑥为学生表创建一个名为,以班级号的升序排序;createindexIX_Classonstudent(ClnoASC);⑦删除IX_Class索引DropindexIX_Class针对以上四个表,用SQL语言完成以下各项查询:①找出所有被学生选修了的课程号;selectdistinctcnofromgrade;②找出01311班女学生的个人信息;se

3、lect*fromstudentwhereclno=01311andssex='女';③找出01311班、01312班的学生姓名、性别、出生年份;Selectsname,ssex,2011-sageas‘出生年份’fromstudentwhereclnoin('01311','01312');④找出所有姓李的学生的个人信息;Select*fromstudentwheresnamelike’李%’;⑤找出学生李勇所在班级的学生人数;Selectnumberfromclasswhereclnoin(selectcln

4、ofromstudentwheresname='李勇');⑥找出课程名为操作系统的平均成绩、最高分、最低分;Selectavg(gmark),max(gmark),min(gmark)fromgradewherecnoin(selectcnofromcoursewherecname='操作系统');⑦找出选修了课程的学生人数;Selectcount(distinctsno)fromgrade;⑧找出选修了课程操作系统的学生人数;Selectcount(distinctsno)fromgradewherecnoin

5、(selectcnofromcoursewherecname='操作系统');⑨找出2000级计算机软件班的成绩为空的学生姓名。Selectsnamefromstudentwhereclnoin(selectclnofromclasswhereinyear=’2000’andspeciality=’计算机软件’)andsnoin(selectsnofromgradewheregmarkisnull);针对以上四个表,用SELECT的嵌套查询完成以下各项查询:①找出与李勇在同一个班级的学生信息;Select*fro

6、mstudentwhereclnoin(selectclnofromstudentwheresname=’李勇’);②找出所有与学生李勇有相同选修课程的学生信息;Select*fromstudentwheresnoin(selectsnofromgradewherecnoin(selectcnofromgradewheresno=(selectsnofromstudentwheresname='李勇')))③找出年龄介于学生李勇和25岁之间的学生信息;Selectsagefromstudentwheresageb

7、etween(selectsagefromstudentwheresname=’李勇’)and25④找出选修了课程操作系统的学生学号和姓名;Selectsno,snamefromstudentwheresnoin(selectsnofromgradewherecnoin(selectcnofromcoursewherecname=’操作系统’))⑤找出所有没有选修1号课程的学生姓名;Selectsnamefromstudentwherenotexists(select*fromgradewheresno=stud

8、ent.snoandcno='1')OR:SelectsnamefromstudentWheresnonotin(SelectsnofromgradeWherecno=’1’);⑥找出选修了全部课程的学生姓名。(提示:可找出这样的学生,没有一门课程是他不选修的。)Selectsnamefromstudentwherenotexists(select*fromcoursew

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。