S2 - SQL - 模拟题一 - 图文(3)

2020-03-27 13:02

select * from student; select * from view_student; 假定上述命令全部执行成功,将各自返回()()行记录。 A. 10,10 B. 10,9

39.sql server数据库中,包含两个表:order订单表, item订单子项目表。

当一个新定单被加入时,数据要分别保存到order和item表中,要保证数据完整性,可以使用以下()语句。(选择一项)

A. begin transaction insert into order values (此处省略) insert into item values (此处省略) end ransaction

B. begin transaction insert into order values (此处省略) insert into item values (此处省略) if (@@error = 0) commit transaction else rollback transaction C. begin transaction insert into order values (此处省略) if (@@error = 0) insert into item values (此处省略) if (@@error = 0) commit transaction else rollback transaction else rollback transaction

D. begin transaction insert into order values (此处省略) insert into item values (此处省略) if (@@error <> 0) rollback transaction

40.现有一个学生信息表student,包含主键studentid (学生编号)。

又有分数表scores,包含studentid(学生编号)、以及 score(考试分数)。

已知student表中共有50个学生,有45人参加了考试(分数存在scores表中),其中10人不及格。执行以下sql语句:

select * from student where exists (select studentid from score where score<60) 可返回()条记录。(选择一项)***

A. 50 B. 45 C. 10 D. 0

C. 9,10 D. 9,9

41.

create table student (

id int identity(1,1), name varchar(20)

)

alter table student add constraint uq_name unique(name) insert into student values(null) insert into student values(null)

insert into student values(‘jack’)

insert into student values(‘jack’)

依次执行以上sql语句后,student表中存在()行记录。

42.在sql server 2005中,现有orders(订单)表,包含字段:cid(顾客编号),pid(产品编号)。若查询既订购了产品p01,又订购了产品p02的顾客编号,可以执行以下()sql语句。 (选择二项)

A. A. select distinct(cid) from orders o1 where o1.pid in (‘p01’,’p02’) A. 1 B. 2 C. 3 D. 4

B. B. select distinct(cid) from orders o1,orders o2 where o1.pid=’p01’ and o2.pid=’p02’and o1.cid=o2.cid C. C. select distinct(cid) from orders o1 where pid=’po1’ and cid in (select cid from orders where pid=’po2’)

D. D. select distinct(cid)from orders o1,orderso2 where o1.pid=’po1’ and o2.pid=’po2’

43.在sql server 2005中,创建存储过程如下,要在students表中查找age(年龄)是18岁的学生,()可以正确的调用这个存储过程。(选择二项) create procedure myp1 @p int as

select studentname,age from students where age = @p

A. exec myp1 18 B. exec myp1 @p=18 C. exec myp1 p='18' D. exec myp1 p=18

44.考虑本地图书馆的一个图书借阅和跟踪系统,在sql server2000数据库中包含三个表:member(会员信息),borrow(借阅记录)和book(图书信息),要求:

1、每人可以借阅一或多本书;

2、每本书一次只能被借给一个人; 3、图书馆没有的书籍不能被借阅;

要在borrow和book表中强制这种数据完整性,下列描述中正确的是()。(选择二项)

A. book表中定义book_id为主键,borrow表中建立外键并与book表的book_id建立引用关系

B. borrow表中定义borrow_id为主键,并对borrow_id列建立检查约束 C. 为book表增加一列来记录书是否被借出

D. borrow表中定义book_id为主键,book表中建立外键并与borrow表的book_id

建立引用关系

45.在sql server2005中,已知course表的主键是course_id,现要创建student表,此表中的course_id列要设为外键,并与course表建立引用关系。下列sql语句能满足上述要求的有()。(选择二项) A. create table

student (stu_id varchar(10)not null,name null,name

varchar(10),course_id int foreign key on course(course_id)) B. create table student (stu_id varchar(10)not

varchar(10),course_id int foreign key references course(course_id)) C. create table student (stu_id varchar(10)not null,name varchar(10),course_id int,foreign key references course(course_id)) D. create table student (stu_id varchar(10)not null,name varchar(10),course_id int,foreign key (course_id)references course(course_id))

46.已知有如下功能:

create proc proc_test

@table_name varchar(20) as

declare @sql varchar(100)

select @sql = ‘select * from ’+@table_name

exec (@sql) go

请问以上语句的运行结果是( )(选择两项)

A. 原子性 B. 一致性 C. 隔离性 D. 持久性 E. 不变性

A. 此存储过程有错,不能执行

B. 此存储过程会打印输出一条sql语句

C. 这是属于exec的另一种用法,用于执行一条sql语句, D. 它执行的结果是查询到用户输入表中的所有信息

47.事务的特性有:()(请选择四项)

48.合并多个表中的数据的方法有哪三种?()

A. B. C. D.

联合 子查询 联接 角色

49.请问以下代码在哪些地方有错()(选择一项)

declare @i int

@i = 1

while(1=1)

begin

-----1 -----2

-----3 -----4

-----5

print @i set @i ++

-----6 -----7

end

A. 1,2,3 B. 2,4,7 C. 2,6

D. 4,5,6,7

50.事务的分类分为:()(选择三项)

A. 显式事务 B. 隐式事务 C. 自动提交事务 D. 隐式提交事务

二. 编程题

1. 现有名为“zuxiaDB”的数据库,功能实现如下:

1.1 .创建普通管理员登录账号 “zuxia”,密码为”123456” 1.2 .为登录账号zuxia创建数据库用户zuxiaUser

1.3 .为数据库用户zuxiaUser授权,对student表的select,update权限。

2. 题意如下:


S2 - SQL - 模拟题一 - 图文(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:c#高级程序员面试题(附部分参考答案)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: