实验二总结报告

上传人:大米 文档编号:554885348 上传时间:2023-07-18 格式:DOCX 页数:19 大小:1.72MB
返回 下载 相关 举报
实验二总结报告_第1页
第1页 / 共19页
实验二总结报告_第2页
第2页 / 共19页
实验二总结报告_第3页
第3页 / 共19页
实验二总结报告_第4页
第4页 / 共19页
实验二总结报告_第5页
第5页 / 共19页
点击查看更多>>
资源描述

《实验二总结报告》由会员分享,可在线阅读,更多相关《实验二总结报告(19页珍藏版)》请在金锄头文库上搜索。

1、数据库原理与应用实验报告实验名称:实验二班 级:软件工程学 号:姓 名:一、实验目的1掌握使用SQL语句创建和删除数据表,创建各种完整性约束。2掌握使用SQL语句修改表的结构。3. 掌握查询语句的使用方法,重点掌握连接查询和嵌套查询。二、实验过程1.使用SQL语句建立4个关系,:供应商表S (Sno, Sname, City)零件表P(Pno, Pname, Color, Weight)工程项目表J(Jno, Jname, City)供应情况表 SPJ(Sno, Pno, Jno, QTY)创建S表的语句为:create table s(sno varchar2(20) primary key

2、, sname varchar2(40) unique, city varchar2(10);语句的执行结果为:创建p表的语句为:create table p(pno varchar2(20) primary key, pname varchar2(40), color varchar2(10), weight number check(weight=1 and weight2;(8)查询零件名以“螺”字开头的零件信息。select * from p where pname like 螺%;(9)查询工程项目名中最后一个字为“厂”字的工程项目所在的城市。select city from j w

3、here jname like %厂;(10)查询给每个工程供应零件的供应商的个数。select jno,count(distinct sno) from spj group by jno;(11)查询供应数量在10002000之间(包括1000和2000)的零件名称。select pname from p where pno in (select pno from spj group by pno having sum(qty)=1000 and sum(qty)200;(6)查询姓名为田丕龙的学生所学课程的课程名与学分。select cname,gredit from course whe

4、re cno in (select cno from sc where sno in (select sno from student where sname=田丕龙));(7)查询选修课程号为“160”或“304”的学生的学号。select sno from sc where cno=160 or cno=304;(8)查询选修了课程号为“160”和“304”的学生的学号。select x.sno from sc x,sc y where x.sno=y.sno and o=160 and o=304;(9)查询学习全部课程的学生姓名。select sname from student wh

5、ere sno in (select sno from sc group by sno having count(cno)= (select count(cno) from course);(10)查询1994年1月1日以前出生的学生的姓名和专业。select sname,major from student where to_date(1994/01/01,yyyy/mm/dd)-birth=0;(11)查询选修了“大学英语4”课程且成绩在90分以上的学生姓名。select sname from student where sno in (select sno from sc where g

6、rade90 and cno in (select cno from course where cname=大学英语4); (12)查询选修了5门以上课程的学生学号和姓名。select sno,sname from student where sno in (select sno from sc group by sno having count(cno)5); (13)查询未选修“政治经济学”课程的学生情况。select * from student where sno!=all (select sno from sc where cno in (select cno from course

7、 where cname=政治经济学);(14)统计102和378号课程的选课人数及平均成绩。select cno,count(sno) 人数,avg(grade) from sc group by cno having cno=102 or cno=378;(15)查询比所有“信息管理与信息系统”专业学生年龄都大的学生。select * from student where birth (select min(birth) from student where major=信息管理与信息系统); (16)将“计算机科学与技术”专业的学生按出生时间先后排序。select * from student where major=计算机科学与技术 order by birth asc;三、实验总结

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > PPT模板库 > 总结/计划/报告

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号