电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

数据库1数据查询VIP免费

数据库1数据查询_第1页
数据库1数据查询_第2页
数据库1数据查询_第3页
实验一数据库查询课程名称:数据库原理实验实验类型:验证型实验名称数据库查询学时4学时实验目的:使学生掌握SQLServerQueryAnalyzer的使用方法,加深对SQL和T-SQL语言的查询语句的理解。熟练掌握表的基本查询,连接查询和嵌套查询,以及掌握数据排序和数据分组的操作方法。实验原理:SELECT[ALL|DISTINCT]<目标列表达式>[,<目标列表达式>]…FROM<表名或视图名>[,<表名或视图名>]…[WHERE<条件表达式>][GROUPBY<列名1>[HAVING<条件表达式>]][orderby<列名2>[ASC|DESC]];实验方法:将查询需求用T-SQL语言表示;在SQLServerQueryAnalyzer的输入区中输入T-SQL查询语句;设置QueryAnalyzer的结果区为StandardExecute(标准执行)或ExecutetoGrid(网格执行)方式;发布执行命令,并在结果区中查看查询结果;如果结果不正确,要进行修改,直到正确为止。实验内容:1.分别用带DISTINCT和不带DISTINCT关键字的SELELCT在student中进行查询.带distinct:Selectclass_idfromstudent不带distinct:selectdistinctclass_idfromstudent2.将teacher表中各教师的姓名、教工号及工资按95%发放的信息,并将工资按95%发放后的列名改为‘预发工资’selectteacher_id,teacher_name,salary*0.95as预发工资fromteacher3.查询course表中所有学分大于2并且成绩不及格的学生的信息.selectdistinctstudent.*fromstudent,course,scwherestudent.student_id=sc.student_idandsc.course_id=course.course_idandcourse.credit>2andsc.grade<604.查询学分在4~8之间的学生信息.(用between..and和复合条件分别实现)selectdistinctstudent.*fromstudent,course,scwherestudent.student_id=sc.student_idandsc.course_id=course.course_idandcourse.creditbetween4and85.从student_course表中查询出学生为“g9940201”,“g9940202”的课程号、学生号以及学分,并按学分降序排列(用in实现)select*fromsc,coursewherestudent_idin('g9940201','g9940202')andcourse.course_id=sc.course_idorderbycourse.creditdesc6.从teacher表中分别检索出姓王的教师的资料,或者姓名的第2个字是远或辉的教师的资料select*fromteacherwhereteacher_namelike'王%'orteacher_namelike'_远%'orteacher_namelike'_辉%'7.查询每个学生及其选修课情况selectstudent_name,course_namefromstudent,sc,coursewheresc.student_id=student.student_idandsc.course_id=course.course_id8.以student表为主体列出每个学生的基本情况及其选课情况,如果学生没有选课,只输出其基本情况selectstudent.*,course.*fromstudentjoinsconstudent.student_id=sc.student_idleftjoincourseoncourse.course_id=sc.course_id9.查询选修dep04_s001号课程且成绩在80分以上的学生信息。(分别用连接,in和exists实现)连接:selectstudent.*fromsc,studentwheresc.student_id=student.student_idandsc.course_id='dep04_s001'andsc.grade>80In:select*fromstudentwherestudent_idin(selectstudent_idfromscwherecourse_id='dep04_s001'andgrade>80)exists:select*fromstudentwhereexists(selectstudent_idfromscwherestudent.student_id=sc.student_idandcourse_id='dep04_s001'andgrade>80)10.查询所有上计算机基础课程的学生的学号、选修课程号以及分数(分别用连接,in和exists实现)连接:selectsc.*fromsc,coursewherecourse.course_name='计算机基础'andcourse.course_id=sc.course_idIn:selectstudent_id,course_id,gradefromscwherecourse_idin(selectcourse_idfromcoursewherecourse_name='计算机基础')exists:selectstudent_id,course_id,gradefromscwhereexists(select*fromcoursewherecourse_id=sc.course_idandcourse_name='计算机基础')11.查询选修了课程名为“数据库基础”的学生学号和姓名(分别用连接,in和exists实现)连接:selectstudent.student_id,student.student_namefromsc,student,coursewherecourse.course_name='数据库开发技术'andsc.student_id=student.student_idandcourse.course_id=sc.course_idIn:selectstudent_...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

慧源书苑+ 关注
实名认证
内容提供者

热爱教育事业,爱好互联网行业

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部