您现在的位置:首页 >> sql实验报告 >> sql server实验报告,数据库实验报告sql,sql视图实验报告,sql实验报告10

sql server实验报告,数据库实验报告sql,sql视图实验报告,sql实验报告10

时间:2012-04-06 来源: 泥巴往事网

课程设计(大作业)报告 课程名称: 数据库原理与技术 设计题目: 学生管理子系统 院 ... 学 号: 200911011 指导教师: 王亚宁 设计时间:2011 年 6 月 10 日 —6 月 15 日 昆 明 ...

闽 南 师 范 大 学 实 验 报 告 班 级 同组人 学号 姓名 成绩 实验日期 2014.11.21 课程名称:MS SQL 程序设计 实验题目:T-SQL 语句的高级应用 1. 掌握多表连接查询、子查询、游标基本概念。

2. 掌握多表连接的各种方法,包括内连接、外连接、交叉连接等。

3. 掌握子查询的方法,包括相关子查询和不相关子查询。

4. 掌握游标处理结果集的基本过程。 实 验 目 的 与 要 求 PC 兼容机。Window xp 以上操作系统,SQL Server 2005 数据库管理系统 实 验 环 境 的 配 置 第 1 页 闽 南 师 大 实 验 报 告 1. 查询没有被任何学生选修的课程编号、课程名称和学分。 select courseno,cname,period from course where courseno not in (select courseno from score) 2. 查询‘C 语言’期末成绩比‘电子技术’课程期末成绩高的所有学生的学号 和姓名。

第一种: select studentno,sname from student where (select final from score join course on score.courseno=course.courseno where cname='C语言'

and student.studentno=score.studentno) >(select final from score join course on score.courseno=course.courseno where student.studentno=score.studentno) 第二种:

select student.studentno,sname from score join student on score.studentno=student.studentno join course on score.courseno=course.courseno where cname='C 语言'

and final >

(select final from score join course on score.courseno=course.courseno where cname='电子技术'

and student.studentno=score.studentno) 第三种 select a.student,sname from score a,score b,student where a.studentno=b.studentno and a.courseno=(select courseno from course where cname='c语言') and b.courseno=(select courseno from course where cname='电子技术') and a.final>b.final and a.studntno=student.studentno cname='电子技术'

and 实 验 内 容 与 具 体 步 骤 3. 查询学生的期末成绩比其选修的所有课程的期末平均成绩低的学生学 号、课程号和期末成绩。 第一种 select studentno, courseno, final from score as a where final <

(select avg(final) from score as b where a.studentno=b.studentno) 第二种 select a.studentno,a.courseno,a.final from score a,score b where a.studentno=b.studnetno group by a.studentno,a.courseno,a.final having a.final<avg(b.final) 第三种 select studentno,courseno,final from score s1 where exists(select * from score s2 where s1.studentno=s2.studentno group by s2.studetno having s1.final<avg(s2.final) 4. 查询至少选修了学生 0922210009 选修的全部课程的学生学号。 select distinct studentno from score as a where not exists (select * from score as b where studentno='0922210009'

and not exists(select * from score as c where a.studentno=c.studentno and b.courseno=c.courseno) ) and studentno!='0922210009' 5. 查询所有班级期末平均成绩的最高分,并将其赋值给变量,通过 print 语句输出。 declare @cj2 float select @cj2=(select top 1 avg(final) order by avg(final) desc) print @cj2 from score join student on score.studentno=student.studentno group by classno 6. 使用游标输出学生姓名、选修课程名称和期末考试成绩。 declare @name nchar(8),@cname nchar(20),@final float declare chengji cursor for select sname,cname,final from score join student on score.studentno=student.studentno join course on course.courseno=score.courseno open chengji fetch NEXT from chengji into @name,@cname,@final while @@fetch_status=0 begin print @name+'|'+@cname+'|'+cast(@final as varchar(8)) fetch NEXT from chengji into end close chengji @name,@cname,@final 7. ①在 score 表中新增等级字段(修改表添加列)②计算学生期末成绩等 级(大于等于 90 为优秀,大于等于 80 小于 90 为良好,大于等于 70 小 于 80 为中等,大于等于 60 小于 70 为及格,小于 60 为不及格) ,使用 游标更新 level 列 第一种: alter table score add level nvarchar(8) declare addlevel cursor for select studentno, courseno,final from score declare @sno nchar(10),@cno nchar(6),@final float open addlevel fetch NEXT from addlevel into @sno,@cno,@final while @@fetch_status=0 begin update score set level= case when @final>=90 then '优秀'

when @final>=80 then '良好'

when @final>=70 then '中等'

when @final>=60 then '及格'

else end where studentno= @sno and courseno=@cno fetch NEXT from addlevel into @sno,@cno,@final end close addlevel '不及格' 第二种: declare @final numeric declare cur_score cursor for select final from score for update of level open cur_score fetch next from cur_score into @final while @@fetch_status = 0 begin update score set level= case when @final>=90 then '优秀'

when @final>=80 then '良好'

when @final>=70 then '中等'

when @final>=60 then '及格' 实 else '不及格'

验 end 内 where current of cur_score 容 fetch NEXT from cur_score into @final 与 end 具 close cur_score 体 deallocate cur_score 步 骤 注:如果填写内容超出表格,自行添加附页。

09 示范班 SQL2000 上机实验报告 SQL Server 2000 实 验 报 告 姓 名:李 奇 轩 院 系:化工学院盐湖系 专 业:09 因材施教 学 号:0922405012 2010-2011 第一学期 1 09 示范班 ...

实验一 实验题目:表的查询 实验类型:设计型 实验地点:综合楼11楼 实验教师:赵朋飞 实验技术人员:关存丽 一、实验目的及要求: 1.理解查询的功能. 2.掌握条件查询、排序...

数据库SQL实验报告 __ 数据库与基本表的建立数据库SQL实验报告 __ 数据库与基本表... 实验 目的(1)掌...('网络 数据库与 应用', '金林樵', 20, 32, 10... 程名称(中文):网...

 
  • 泥巴往事网(www.nbwtv.com) © 2014 版权所有 All Rights Reserved.