数据库系统原理.docx

上传人:b****0 文档编号:17172754 上传时间:2023-07-22 格式:DOCX 页数:9 大小:198.69KB
下载 相关 举报
数据库系统原理.docx_第1页
第1页 / 共9页
数据库系统原理.docx_第2页
第2页 / 共9页
数据库系统原理.docx_第3页
第3页 / 共9页
数据库系统原理.docx_第4页
第4页 / 共9页
数据库系统原理.docx_第5页
第5页 / 共9页
数据库系统原理.docx_第6页
第6页 / 共9页
数据库系统原理.docx_第7页
第7页 / 共9页
数据库系统原理.docx_第8页
第8页 / 共9页
数据库系统原理.docx_第9页
第9页 / 共9页
亲,该文档总共9页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

数据库系统原理.docx

《数据库系统原理.docx》由会员分享,可在线阅读,更多相关《数据库系统原理.docx(9页珍藏版)》请在冰点文库上搜索。

数据库系统原理.docx

数据库系统原理

《数据库系统原理》实验报告

姓名:

指导教师:

学号:

实验日期:

2016/6/7

一、实验目的

2、用SQL语句建立上述表,自定义主键和外键,对于student表建立约束条件:

ssex仅能取male或female;sage在18和22之间。

并完成下面的查询语句。

1、查询所有选修过“Bibliometrics”课的学生的姓名和成绩;

mysql>selects.sname,sc.gradefromstudentass,scwheres.snoin(selectsnofromscwheregrade>=60andcno='C05')and

sc.gradein(selectgradefromscwheregrade>=60andcno='C05');

2、查询考试成绩不及格的学生的个数;

mysql>selectcount(*)fromscwheregrade<60;

3、查询名字中至少含有一个“z”字符的学生的姓名、学号和性别;

mysql>selectsname,sno,ssexfromstudentwheresnamelike'%z%';

4、查询选修了“IntroductiontotheInternet”课程的学生的学号及其成绩,查询结果按分数的降序排列;

mysql>selectsno,gradefromscwherecnoin(selectcnofromcoursewherecnamelike"Introd%to%Inter%")orderbygradedesc;

5、查询“Zuoli”同学选修课程的总学时(time)数

mysql>selectsum(c.ctime)fromcoursecwherecnoin(selectcnofromscwheresnoin(selectsnofromstudentwheresname='Zuoli'));

6、查询年龄不大于20岁的学生的平均考试成绩;

mysql>selectavg(grade)fromscwheresnoin(selectsnofromstudentwheresage<=20);

7、查询“computerscience”专业学生选修“DatabaseSystem”的人数;

mysql>selectdistinctcount(sno)fromscwherecnoin(selectcnofromcoursewherecnamelike"D%Syst%")andsnoin(Selectsnofromstudentwheresdeptlike"compu%");

8、查询同时选修课程“DatabaseSystem”和“IntroductiontotheInternet”的学生姓名;

mysql>selectsnamefromstudentwheresnoin(selectsnofromscwherecnoin(selectcnofromcoursewherecnamelike"D%S%")union(selectcnofromcoursewherecnamelike'In%to%the%'));

9、查询选修的课程中含有“Wanggang”同学所有选修课程的学生姓名。

mysql>selectsnamefromstudentwheresnoin(selectsnofromscwherecnoin(selectcnofromscwheresnoin(selectsnofromstudentwheresname='Wanggang')));

10、查询“InformationTechnologyforInformationManagement”考试成绩为空的学生姓名及专业名称。

mysql>selectsname,sdeptfromstudentwheresnoin(selectsnofromscwheregradeisnull);

11、查询“computerscience”专业学生每个人的选修课总学分。

mysql>selectavg(grade)fromscwheresnoin(selectsnofromstudentwheresdeptlike'compu%');

12、查询个人考试平均成绩高于专业平均成绩的学生姓名

mysql>selectstu.snamefromstudentasstuwherestu.snoin(selectsnofromscwhere(selectavg(grade)fromscwheresno=stu.sno)>(selectavg(grade)fromsc));

13、查询个人考试平均成绩高于女生平均成绩的男生姓名

mysql>selectsnamefromstudentasstuwherestu.ssex='male'andstu.snoin(selectsnofromscwhere(selectavg(grade)fromscwheresno=stu.sno)>(selectavg(grade)fromscwheresnoin(selectsnofromstudentwheressex='female')));

14、查询比“computerscience”专业所有学生年龄都大的学生姓名。

mysql>select*fromstudentwheresdeptlike"com%"andsagein(selectmax(sage)fromstudentwheresdeptlike'com%');

15、查询考试成绩仅有一科不及格学生姓名

mysql>selectstu.snamefromstudentasstuwherestu.snoin(selectsnofromscwhere(selectcount(grade)fromscwhe

resno=stu.snoandgrade<60)=1);

 

THANKS!

!

!

 

致力为企业和个人提供合同协议,策划案计划书,学习课件等等

打造全网一站式需求

欢迎您的下载,资料仅供参考

 

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2