sql数据库期末考试题及答案 联系客服

发布时间 : 星期日 文章sql数据库期末考试题及答案更新完毕开始阅读5878246e15791711cc7931b765ce0508763275b3

4、为student表创建一个名称为my_trig的触发器,当用户成功删除该表中的一条或多条记录时,触发器自动删除SC表中与之有关的记录。

(注:在创建触发器之前要判断是否有同名的触发器存在,若存在则删除之。)(7分)

参考答案

一、 单项选择题(每题2分,共15题) 1. C 2.B 3.D 4.C 5.B 6.B 7.C 8.C 9.A 10.D 11.D 12.D 13.C 14.D 15.D

二、 填空题(每空2分,共15空) 1.数据共享 可控冗余 2.GO 3. 64KB 4.非聚集索引 5.AVG函数 6.游标结果集 游标位置 7.一致性 隔离性 8.CREATE DATABASE ALTER DATABASE 9.约束 默认值

三、 简答(10分)

1.DECLARE cname char(16)

SET cname=’数据库系统概述’ 或者是

DECLARE cname char(16)

SELECT cname=’数据库系统概述’ 2.CHAR(13)+CHAR(10) 四、 程序阅读题(5分) 1. name P as

2. EXEC my_proc 7,‘李好’,‘考试书店’或者 EXEC my_proc @a=7,@b=‘李好’,@c=‘考试书店’

五、 编程题(25分,共4题) 1、 (4分)

update course (1分) set 学分=4 (2分)

where课程号=2 (1分)

2、select * from student where 年龄>18 order by 学号 desc (5分) 1分 1分 1分 2分 3、(6分) 方法1:

select distinct student.学号,姓名,性别 (1分)

from student, course, sc (1分)

where (student.学号=sc.学号) and (course.课程号=sc.课程号)

and (course.学分=4) and (sc.成绩>80) (1+1+1+1分) 方法2:

select distinct student.学号,姓名,性别 (1分)

from student Inner Join (sc Inner Join course On course.课程号=sc.课程号)

On student.学号=sc.学号 (2分+2分) where (course.学分=4) and (sc.成绩>80) (1分+1分) 4、(10分)

If exists(Select name From sysobjects Where name=’my_trig’and type=’tr’) (整个If语句 1分)

Drop trigger my_trig (0.5分) Go (0.5分)

Create trigger my_trig (1分) On student (0.5分)

For Delete (1分) As (0.5分)

Delete From sc (2分)

Where 学号 in (Select 学号 From Deleted) (1分+2分) Go