数据的库1数据的查询.doc
《数据的库1数据的查询.doc》由会员分享,可在线阅读,更多相关《数据的库1数据的查询.doc(14页珍藏版)》请在课桌文档上搜索。
1、实验一 数据库查询课程名称:数据库原理实验实验类型:验证型实验名称数据库查询学时4学时实验目的:使学生掌握SQL Server Query Analyzer的使用方法,加深对SQL和T-SQL语言的查询语句的理解。熟练掌握表的根本查询,连接查询和嵌套查询,以与掌握数据排序和数据分组的操作方法。实验原理:SELECT ALL|DISTINCT ,FROM ,WHERE GROUP BY HAVING order by ASC|DESC;实验方法:将查询需求用T-SQL语言表示;在SQL Server Query Analyzer的输入区中输入T-SQL查询语句;设置 Query Analyzer
2、的结果区为Standard Execute标准执行或Execute to Grid网格执行方式;发布执行命令,并在结果区中查看查询结果;如果结果不正确,要进展修改,直到正确为止。实验内容:1. 分别用带DISTINCT和不带DISTINCT关键字的SELELCT在student中进展查询.带distinct:Selectclass_id from student不带distinct:selectdistinct class_id from student2. 将teacher表中各教师的某某、教工号与工资按95发放的信息,并将工资按95发放后的列名改为预发工资select teacher_id
3、,teacher_name,salary*0.95 as 预发工资from teacher3. 查询course表中所有学分大于2并且成绩不与格的学生的信息.selectdistinct student.*from student,course,sc where student.student_id=sc.student_id and sc.course_id=course.course_id and course.credit2 and sc.grade80In:select*from student where student_id in(select student_id fromsc
4、where course_id=dep04_s001and grade80)exists:select*from student whereexists(select student_id from sc where student.student_id=sc.student_id andcourse_id=dep04_s001and grade80)10. 查询所有上计算机根底课程的学生的学号、选修课程号以与分数分别用连接,in和exists实现连接:select sc.*from sc,course where course.course_name=计算机根底and course.cour
5、se_id=sc.course_idIn:select student_id,course_id,grade from sc where course_id in(select course_id from course where course_name=计算机根底)exists:select student_id,course_id,grade from sc whereexists(select*from course where course_id=sc.course_id and course_name=计算机根底)11. 查询选修了课程名为“数据库根底的学生学号和某某分别用连接,i
6、n和exists实现连接:select student.student_id,student.student_name from sc,student,course where course.course_name=数据库开发技术and sc.student_id=student.student_id and course.course_id=sc.course_idIn:select student_id,student_name from student where student_id in(select student_id from sc where course_id=(selec
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据 查询

链接地址:https://www.desk33.com/p-26279.html