数据库实验答案.doc_第1页
数据库实验答案.doc_第2页
数据库实验答案.doc_第3页
数据库实验答案.doc_第4页
数据库实验答案.doc_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

实验3 使用T-SQL语言完成单表查询一、 实验目的掌握使用T-SQL语言完成单表查询掌握常用谓词的用法掌握where子句的用法掌握order by 子句的用法掌握group by 子句和having短语的用法二、 实验环境Microsoft SQL Server 2000。三、 实验内容和要求1. 查询全体学生的详细信息。2. 查询所有课程的详细信息。3. 查询所有选课记录的详细信息,要结果表中的列名以中文的形式显示,分别为:学号,课程号,成绩。4. 查询已被学生选修了的课程的编号。5. 查询系别编号为“d002”的学生的姓名和性别。6. 查询年龄在19至21岁或者性别为“女”的学生的学号和所在系别编号。7. 查询系别编号为d001、d002和d003的学生的学号和姓名。8. 查询课程名为“C_”开头的课程名和学分。9. 某些学生入学后还没有确定所在的系,查询还没有确定系的学生的姓名。10. 查询成绩大于60分的学生的学号、课程号和成绩,并将查询结果按课程编号升序排列,同一课程的成绩按分数降序排列。11. 查询学校所开设的总的课程数。12. 计算2号课的学生成绩总和以及平均成绩,对应的列名分别为“总成绩”和“平均成绩”。13. 查询选修了3号课程的学生的最高分和最低分,对应的列名分别为“最高分”和“最低分”。14. 求各个系别的编号以及各系的人数。15. 查询选课人数大于等于2人的课程编号以及选课的人数。16. 查询学生选修课程的总成绩对应的列名为“总成绩”,并显示出学号。17. 查询有2门以上课程是80分以上的学生的学号及课程数。18. 查询选修了1号课的学生的学号和成绩,结果按成绩降序、学号升序排列。实验1 使用T-SQL语言建库、建表实验2 向表中增、删、改数据四、 实验目的掌握使用T-SQL建库、建表、修改表;掌握使用T-SQL对表中数据进行插入、删除和修改。五、 实验环境Microsoft SQL Server 2000。六、 实验内容和要求19. 建立数据库STDB20. 在数据库STDB中建立四个表:Student表列名类型约束或索引说明SnoChar(9)主键约束学号SnameVarchar(20)非空约束姓名SsexChar(2)性别sageInt年龄deptnoChar(10)外键约束所在系别编号Department表列名类型约束或索引说明DeptnoChar(10)主键约束系别编号dnameVarchar(50)唯一索引系名称Course表列名类型约束或索引说明CnoChar(4)主键约束课程编号cnameVarchar(40)唯一约束课程名称CpnoChar(4)先行课Ccreditsmallint学分Sc表列名类型约束或索引说明SnoChar(9)外键约束,与cno共同构成主键学号CnoChar(4)外键约束,与sno共同构成主键课程编号gradeint成绩21. 分别向以上四个表中增加数据。department表:Student表:Course表:SC表:22. 将学生的年龄改为21岁。23. 将所有学生的所有成绩增加5分。24. 删除7号课程的记录。25. 向学生表增加新列“血型”,并记录下学生表中已存在学生的血型信息。实验4 使用T-SQL语言完成多表查询七、 实验目的掌握使用T-SQL语言完成等值连接查询掌握使用T-SQL语言完成自身连接查询掌握使用T-SQL语言完成外连接查询掌握使用T-SQL语言完成嵌套查询掌握使用T-SQL语言完成集合查询掌握常用谓词在嵌套查询中的用法八、 实验环境Microsoft SQL Server 2000。九、 实验内容和要求26. 查询每个学生的学号、姓名、性别、所在系的名称、选修的课程名、学分以及成绩。27. 查询所有课程的课程编号、课程名称、学分、选修该课程的学生编号以及成绩。28. 查询选修了1号课程且不及格的学生的学号、姓名。(要求分别用连接查询和嵌套查询完成)29. 查询姓名为“刘晨”的学生选修的课程名和学分。(要求分别用连接查询和嵌套查询完成)30. 查询CS系、IS系和MA系的学生的学号、姓名和性别。31. 查询号同学选修课程的总学分数,显示出姓名和总学分数。32. 找出每个学生小于他选修课程平均成绩的学号和课程号。33. 查询号同学所选修的课程中,成绩低于其他同学选修的某一课程成绩的课程,要求显示出其课程号和成绩。34. 查询号同学所选修的课程中,成绩低于其他有成绩的同学选修的所有课程成绩的课程,要求显示出其课程号和成绩。35. 查询号同学选修课程的课程号和课程名。(要求分别使用包含EXISTS谓词的嵌套查询以及连接查询完成)36. 查询既选修了课程1又选修了课程2的学生的学号。(要求使用嵌套查询完成)37. 查询选修了课程1或者选修了课程2的学生的学号。(要求分别用集合查询和多重条件查询完成)-实验1、2create database stdb1go use stdb1gocreate table department( deptno char(10) primary key, dname varchar(50)gocreate unique index deptname on department(dname)gocreate table student( sno char(9) primary key, sname varchar(20) not null, ssex char(2), sage int, deptno char(10), foreign key (deptno) references department(deptno) )create table course( cno char(4) primary key, cname varchar(40) unique, cpno char(4), ccredit smallint)gocreate table sc( sno char(9), cno char(4), grade int, primary key(sno,cno), foreign key (sno) references student(sno), foreign key (cno) references course(cno) )-3insert into department values(d001,cs)insert into department values(d002,is)insert into department values(d003,ma)insert into student values(,李勇,男,20,d001)insert into student values(,刘晨,女,20,d001)insert into student values(,王敏,女,20,d002)insert into student values(,张立,男,20,d003)insert into student values(,陈天华,男,20,d003)insert into student values(,宋阳,女,20,d002)insert into course values(1,数据库,5,4)insert into course values(2,数学,null,2)insert into course values(3,信息系统,1,4)insert into course values(4,操作系统,6,3)insert into course values(5,数据结构,7,4)insert into course values(6,数据处理,null,2)insert into course values(7,PASCAL语言,6,4)insert into course values(8,C_语言,null,4)insert into sc values(,1,92)insert into sc values(,2,85)insert into sc values(,3,88)insert into sc values(,4,72)insert into sc values(,5,65)insert into sc values(,6,58)insert into sc values(,8,68)insert into sc values(,9,68)insert into sc values(,2,90)insert into sc values(,3,80)insert into sc values(,1,null)-4update student set sage=21 where sno=-5update sc set grade=grade+5-6delete from course where cno=7-7alter table student add bloodtype varchar(10)update student set bloodtype=A where sno=update student set bloodtype=B where sno=update student set bloodtype=O where sno=update student set bloodtype=AB where sno=update student set bloodtype=A where sno=update student set bloodtype=B where sno=-1.查询每个学生的学号、姓名、性别、所在系的名称、选修的课程名、学分以及成绩。select student.sno,sname,ssex,dname,cname,ccredit ,grade from student,course,department,scwhere student.sno=sc.sno and student.deptno=department.deptno and o=o-2.查询所有课程的课程编号、课程名称、学分、选修该课程的学生编号以及成绩。select o,cname,ccredit,sc.sno,grade from sc,course where o=o-3.查询选修了1号课程且不及格的学生的学号、姓名。(要求分别用连接查询和嵌套查询完成)select sc.sno,sname,grade from sc,student where sc.sno=student.sno and cno=1 and grade60select sno,sname from student where sno in(select sno from sc where cno=1 and grade60)-4.查询姓名为“刘晨”的学生选修的课程名和学分。(要求分别用连接查询和嵌套查询完成)select cname,ccredit from sc,course,student where o=o and sc.sno=student.sno and sname=刘晨select cname,ccredit from course where cno in (select cno from sc where sno in(select sno from student where sname=刘晨) )-5.查询CS系、IS系和MA系的学生的学号、姓名和性别。select sno,sname,ssex from student,department where student.deptno=department.deptno and dname in (cs,is,ma)select sno,sname,ssex from student,department where student.deptno=department.deptno and (dname =csor dname=is or dname=ma)-6.查询号同学选修课程的总学分数,显示出姓名和总学分数。select sname,sum(ccredit) from student,sc,course where student.sno=sc.sno and o=oand sc.sno=group by sname-7.找出每个学生小于他选修课程平均成绩的学号和课程号。select sno,cno from sc xwhere grade(select avg(grade) from sc y where x.sno=y.sno )-8.查询号同学所选修的课程中,成绩低于其他同学选修的某一课程成绩的课程,要求显示出其课程号和成绩。select cno,grade from scwhere sno= and grade any (select grade from sc where sno)select cno,grade from scwhere sno= and grade (select max(grade) from sc where sno)-9.查询号同学所选修的课程中,成绩低于其他有成绩的同学选修的所有课程成绩的课程,要求显示出其课程号和成绩。select cno,grade from scwhere sno= and grade all (select grade from sc where sno and grade is not null)select cno,grade from scwhere sno= and grade (select min(grade) from sc where sno and grade is not null)-10.查询号同学选修课程的课程号和课程名。(要求分别使用包含EXISTS谓词的嵌套查询以及连接查询完成)select o,cname from course,sc where o=o and sno=select cno,cname from course where cno in(select cno from sc where sno=)select cno,cname from course where exists (select * from sc where o=o and sno=)-11.查询既选修了课程1又选修了课程2的学生的学号。(要求使用嵌套查询完成)select sno from sc where cno=1 and sno in(select sno from sc where cno=2)select sno from sc x where cno=1 and 2 in(select cno from sc y where x.sno=y.sno)-12.查询选修了课程1或者选修了课程2的学生的学号。(要求分别用集合查询和多重条件查询完成)select distinct sno from sc where cno=1 or cno=2select sno from sc where cno=1unionselect sno from sc where cno=2-1select * from student-2select * from course-3select sno 学号,cno 课程号,grade 成绩 from sc-4select distinct cno from sc-5select sname,ssex from student where deptno=d002-6select sno,deptno from student where sage between 21 and 22 or ssex=女-7select sno,sname from student where deptno=d001 or deptno=d002 or deptno=d003-8select cname,ccredit from course where cname like C_% escape -9select sname from student where deptno is null-10select sno,cno,grade from sc where grade 60 order by cno,grade desc-11select count(*) from course-12select sum(grade) 总成绩,avg(grade) 平均成绩 from sc where cno=2-13select max(grade) 最高分,min(grade) 最低分 from sc where cno=3-14select deptno, count(sno) from student group by deptnoselect * from student-15select cno, count(sno) from sc group by cno having count(sno)=2select * from sc-16select sno, sum(grade) 总成绩 from sc where sno= group by sno-17select sno,count(cno) from sc where grade 80 group by sno having count(*)2-18select sno, grade from sc where cno=1 order by grade de为搞好山东省交通科学研究所研发基地项目的结算审计工作,我跟踪审计部特针对本项目作如下要求,请各施工单位、供货单位遵照执行:and performance test copies of the record. If necessary, review should be carried out; 4) for spring hangers (included simple spring, hangers and constant support hangers) it should also be recognized as setting and locking of loads. 5) check the surface quality, folded layering and without cracks, rust and other defects. 5) after completion of the test and control drawing number one by one, by series baled. Color alloy steel parts, the parts marking installation location and rotation about the direction you want. 7.3.14. hangers installation hanger layout a. a clear design of hanger should be installed strictly in accordance with the drawings and designs shall not be installed wrong, missing, etc. B. own arrangement of piping support and hanger set and selection should be based on comprehensive analysis of general layout of piping systems; cold installation of steam pipe with particular attention reserved for compensation of thermal expansion displacement and orientation. C. support systems

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论