数据库视图和索引-游标实验报告

上传人:F****n 文档编号:99252747 上传时间:2019-09-18 格式:DOC 页数:9 大小:310KB
返回 下载 相关 举报
数据库视图和索引-游标实验报告_第1页
第1页 / 共9页
数据库视图和索引-游标实验报告_第2页
第2页 / 共9页
数据库视图和索引-游标实验报告_第3页
第3页 / 共9页
数据库视图和索引-游标实验报告_第4页
第4页 / 共9页
数据库视图和索引-游标实验报告_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《数据库视图和索引-游标实验报告》由会员分享,可在线阅读,更多相关《数据库视图和索引-游标实验报告(9页珍藏版)》请在金锄头文库上搜索。

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 instructor.name, advisor.i_ID,advisor.s_ID,student.ID,student.nameFrom student,instructor,advisorWhere instructor.name = 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,instructor.namefrom 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.name,student.dept_name, student.tot_credfrom instructor,student,advisorwhere instructor.name=Einstein and instructor.I

10、D=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 id ,name,dept_name ,tot_credENDclose studentDEALLOCATE student四、实验结果及分析和(或)源程序调试过程实验三:1.执行结果如下: 2.a命令成功完成。2.b命令成功完成。2.c命令成功完成。2.d命令成功完成。实验四:1.命令成功完成。2.命令成功完成。考虑到公司仍有部分低层及高层人员的补充,因此在选择招聘渠道供应商的附加值时以配送普工现场招聘会和高端人才交流会为佳,另外根据供应商平台实力,若能给公司提供合适的猎头服务也应当纳入甄选范畴。

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 教学/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号