版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、数据库系统实验报告年级、专业、班级2011级计科4班姓名XX实验题目视图和索引 游标实验时间 2013/10/25实验地点A主414实验成绩 实验性质验证性 设计性 综合性教师评价:算法/实验过程正确; 源程序/实验内容提交 程序结构/实验步骤合理;实验结果正确; 语法、语义正确; 报告规范; 其他: 评价教师签名:一、实验目的1.学习并掌握视图的创建、使用、修改和删除。2.学习并掌握索引的创建和使用。3.学习并掌握数据库的连接操作。4.掌握transact-SQL的变量定义方法。5.了解并掌握游标的定义。6.了解并掌握声明、打开、提取、关闭和释放游标。7.了解并掌握使用游标修改数据。二、实验
2、项目内容实验三:1.(改编自3.1a.)建立视图,它给出了名叫Einstein的教师所教的所有学生的信息,保证结果中没有重复。2.用SQL查询语句写出下面的查询。a.显示所有教师的列表,列出他们的ID,姓名以及所讲授的课程段的编号。对于没有讲授任何课程段的教师,确保将课程段的编号显示为0。在你的查询中应该使用外连接,不能使用标量子查询。b.使用标量子查询,不能使用外连接写出上述查询。c显示2010年春季开设的所有课程的列表,包括讲授教程段的教师的姓名。如果一个课程段有不止一位教师讲授,那么有多少位教师,此课程段在结果中就出现多少次。如果一个课程段没有任何教授,他也要出现在结果中,相应的教师名设
3、置为“”。d显示所有系的列表,包括每个系中教师的总数,不能使用标量子查询。确保正确处理没有教师的系。4.2 不使用SQL外连接运算也可以在SQL中计算外连接表达式。为了阐明这个事实,不使用外连接表达式重写下面的SQL查询。aselect *from student natural left outer join takesb.select * from student natural full outer join takes 实验四:1. 用游标的方式完成,3.3a使用大学模式,给Comp.Sci. 系的每位老师涨10%的工资。2. (改编自3.1a.)用游标的方式完成, 使用大学模式,找出
4、名叫Einstein的教师所教的所有学生的表示,保证结果中没有重复,并将他们赋值给变量student1、student 2、student n三、实验过程或算法(源程序)实验三:1.Create view Einstein_studentAsSelect distinct , advisor.i_ID,advisor.s_ID,student.ID,From student,instructor,advisorWhere = Einstein and advisor.i_ID=22222 and adviso
5、r.s_ID = student.ID2.a.select *from instructor left outer join teacheson instructor.ID = teaches.IDb.select ID,name,(select count(course_id) as bianhaofrom teaches where teaches.ID=instructor.ID)from instructorc.select teaches.course_id,from teaches,instructorwhere teaches.semester= S
6、pring and teaches.year=2010 and teaches.ID=instructor.IDd.select *from department left outer join instructoron department.dept_name = instructor.dept_name3.a.select *from student natural join takesunionselect ID,name,dept_name,tot_cred,NULL,NULL,NULL,NULL,NULL,NULLfrom student where not exists(selec
7、t ID from takes where takes.ID = student.ID)b.(select * from student natural join takes)union(select ID,name,dept_name,tot_cred,NULL,NULL,NULL,NULL,NULL,NULL from student where not exists(select ID from takes where takes.ID = student.ID)union(select ID,name,dept_name,tot_cred,NULL,NULL,NULL,NULL,NUL
8、L,NULL from takes where not exists(select ID from student where takes.ID = student.ID)实验四:1.begin trandeclare upsa cursor forselect *from instructorwhere dept_name = Comp. Sci.open upsafetch next from upsaupdate instructorset salary = salary * 1.10where current of upsawhile FETCH_STATUS =0beginfetch
9、 next from upsaupdate instructorset salary = salary * 1.10where current of upsaendcommit tranclose upsadeallocate upsa2.declare student cursor For select distinct student.ID,,student.dept_name, student.tot_credfrom instructor,student,advisorwhere =Einstein and instructor.ID=advisor.i_ID and advisor.s_ID =student.IDfor read onlydeclare id char(20),name char(20),dept_name char(20) ,tot_cred char(20)open studentfetch next From student into id ,name,dept_name ,tot_credWHILE FETCH_STATUS = 0BEGINPRINT id +name+dept_name+tot_credfetch next From student into i
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 快递信息处理员成果强化考核试卷含答案
- 己二腈装置操作工岗前竞争分析考核试卷含答案
- 方便面制作工岗前安全检查考核试卷含答案
- 海洋环境监测员操作评估能力考核试卷含答案
- 电力电容器真空浸渍工安全生产基础知识强化考核试卷含答案
- 快件处理员安全技能测试考核试卷含答案
- 生物柴油装置操作工安全知识宣贯考核试卷含答案
- 2024年益阳职业技术学院辅导员招聘考试真题汇编附答案
- 油锯工岗前趋势考核试卷含答案
- 铝电解工岗前技术操作考核试卷含答案
- 陕西省西安市(2024年-2025年小学三年级语文)人教版质量测试(下学期)试卷(含答案)
- 部编人教版四年级语文上册期末试卷及答案1套
- 11340《古代小说戏曲专题》【纸考】2023.12
- 江苏省南通市启东市2023-2024学年九年级上学期期末考试英语模拟试题(含听力)附答案
- 基于机器学习的缺陷预测技术
- 挡土墙、围墙石砌体作业安全措施
- 工程勘察设计收费标准(2002年修订本)完整版
- GB/T 34956-2017大气辐射影响航空电子设备单粒子效应防护设计指南
- 三菱扶梯介绍PLUS概述课件
- 江西乐平工业园区污水处理厂提标改造工程环评报告书
- 劳务作业分包劳务分包技术方案
评论
0/150
提交评论