北邮数据库实验报告(共17页).docx





《北邮数据库实验报告(共17页).docx》由会员分享,可在线阅读,更多相关《北邮数据库实验报告(共17页).docx(17页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上数据库实验报告(四)姓名: 学号: 班级: 1. 简单查询:(1) 查询“数据库开发技术”课程的学分;SQL语句:select creditfrom coursewhere course_name=SQL Server数据库开发技术;或者模糊查询:select creditfrom coursewhere course_name like %数据库开发技术;执行结果:(2) 查询选修了课程编号为“dep04_s004”的学生的学号和成绩,并将成绩按降序输出;SQL语句:select student_id,gradefrom student_coursewhere co
2、urse_id=dep04_s003order by grade desc;执行结果:(3) 查询学号为“g”的学生选修的课程编号和成绩;SQL语句:select course_id,gradefrom student_coursewhere student_id=g;执行结果:(4) 查询选修了课程编号为“dep04_s001”且成绩高于85分的学生的学号和成绩。SQL语句:select student_id,gradefrom student_coursewhere course_id=dep04_s001 and grade85;执行结果:2. 在多表连接的查询实验中,用Transact
3、 SQL语句完成以下查询操作:(1)查询选修了课程编号为“dep04_s002”且成绩高于85分的学生的学号、姓名和成绩;SQL语句:select student.student_id,student_name,gradefrom student,student_coursewhere student.student_id=student_course.student_id and student_course.course_id=dep04_s002 and student_course.grade85;执行结果:(2)查询所有学生的学号、姓名、选修的课程名称和成绩;SQL语句:select
4、 student.student_id,student_name,course_name,gradefrom student,course,student_coursewhere student.student_id=student_course.student_id and student_course.course_id=course.course_id;执行结果:(3)查询林红同学选修的课程名称、学分和成绩。(考试成绩60有学分,否则无学分。)SQL语句:select course_name,student_course.credit,gradefrom student,student_
5、course,coursewhere student_name=林红 and student.student_id=student_course.student_idand student_course.course_id=course.course_id;3. 在复杂查询实验中,用Transact SQL语句完成以下查询操作:(1)查询至少选修了三门课程的学生的学号和姓名;SQL语句:select student.student_id,student_namefrom student,student_coursewhere student.student_id=student_course.
6、student_id group by student.student_id,student_name having count(student_course.course_id)=3;执行结果:(2)查询选修课程号为“dep04_b001”的学生的平均成绩;SQL语句:select avg(grade)from student_coursewhere course_id=dep04_b001;执行结果:(3)查询所有学生的学号和他选修课程的最高成绩,要求他的选修课程中没有成绩为空的。SQL语句:select student_id,max(grade)from student_coursewh
7、ere exists(select grade from student_course)group by student_id;执行结果:(4) 查询严为老师2001/2002学年教的软件开发技术课程的最高成绩及此学生的学号、姓名、班级。SQL语句:select student.student_id,student_name,student.class_id,gradefrom teacher_course_class,teacher,course,student,student_coursewhere teacher_course_class.teacher_id = teacher.tea
8、cher_id and teacher.teacher_name = 严为 and teacher_course_class.course_id = course.course_id and course.course_name = 软件开发技术 and teacher_course_class.course_id = student_course.course_id and student_course.student_id = student.student_id and teacher_course_class.school_year = 2001/2002 and student_co
9、urse.grade=all(select grade from student_course,course where student_course.course_id = course.course_id and course.course_name = 软件开发技术);执行结果:(5) 查询数据库开发技术课程用过的教材名称,作者和出版社。SQL语句:select book_name,author,publish_companyfrom book,coursewhere course.book_id=book.book_id and course_name=SQL SERVER数据库开发技
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据库 实验 报告 17

限制150内