S2SQL模拟题一蒋航.docx

上传人:b****4 文档编号:5192017 上传时间:2022-12-13 格式:DOCX 页数:20 大小:25.27KB
下载 相关 举报
S2SQL模拟题一蒋航.docx_第1页
第1页 / 共20页
S2SQL模拟题一蒋航.docx_第2页
第2页 / 共20页
S2SQL模拟题一蒋航.docx_第3页
第3页 / 共20页
S2SQL模拟题一蒋航.docx_第4页
第4页 / 共20页
S2SQL模拟题一蒋航.docx_第5页
第5页 / 共20页
点击查看更多>>
下载资源
资源描述

S2SQL模拟题一蒋航.docx

《S2SQL模拟题一蒋航.docx》由会员分享,可在线阅读,更多相关《S2SQL模拟题一蒋航.docx(20页珍藏版)》请在冰豆网上搜索。

S2SQL模拟题一蒋航.docx

S2SQL模拟题一蒋航

S2-SQL-模拟题一-蒋航

s2_sql高级编程

一:

单选(共41问,每问2分)

1:

sqlserver2005中,()关键字标志着批处理的结束。

(选择一项)

A.end

B.go

C.finish

D.print

答案:

b

评:

批处理结束的标志是:

go

所在章节:

第三章

2:

sqlserver2005中,使用t-sql编程时,下列()语句可以从while语句块中退出。

(选择一项)

A.continue

B.exit

C.break

D.close

答案:

c

评:

break中断循环

所在章节:

第四章

3:

sqlserver2000中,使用t_sql编程时,对变量赋值可以使用()或()语句。

(选择一项)

A.setselect

B.printselect

C.setmake

D.printset

答案:

a

评:

对变量赋值只能是set或select,select还可从查询中赋值

所在章节:

第三章

4:

sqlserver2005中,要对用户表(user)建立一个约束,保证注册日期(registerdata)默认使用系统当前日期,下面语句正确的是()。

(选择一项)

A.altertableuseraddconstraintck_datecheck(registerdate=getdate())

B.altertableuseraddconstraintdf_datedefault(getdate())

C.altertableuseraddconstraintdf_datedefault(getdate())forregisterdate

D.altertableuseraddconstraintdf_datedefault(registerdate=getdate())

答案:

c

所在章节:

第二章

评:

添加默认约束的语法:

altertable表名addconstraint约束名default(值)for列名

5:

在sqlserver2005的中,给定创建视图的代码如下:

createviewabcd___select*fromsaleswhereqty>90

则下划线处应填写的正确关键字为()。

(选择一项)

A.on

B.as

C.alter

D.for

答案:

b

所在章节:

第五章

评:

创建视图的语法:

createview视图名assql语句

6:

在sqlserver2005中,对存储过程的描述中正确的是()。

(选择一项)

A.定义了一个有相关列和行的集合

B.它根据一列或多列的值,提供对数据库表的行的快速访问

C.当用户修改数据时,一种特殊形式的存储过程被自动执行

D.sql语句的预编译集合

答案:

d

所在章节:

第六章

评:

存储过程执行速度快,一次编译多次执行,是一条或多条sql语句的集合

7:

sqlserver2000中,创建存在储过程的片断如下:

创建成功后,以下()调用方式是正确的。

(选择一项)

createprocedureproc_score

@passedint=60,

@countintoutput

as

select@count=count(*)fromscorewherescore<@passed

A.executeproc_score@countintoutput

B.declare@countintexecuteproc_score70,@countoutput

C.declare@countintoutputexecuteproc_score70,@countt

D.executeproc_score@passed=70,@countoutput

答案:

b

所在章节:

第六章

评:

:

执行存储过程时,输入参数如果不带默认值,那么要传参,如果带默认值,那么可传入也可以不传入参数;输出参数必须要定义变量来接收

8:

在sqlserver查询分析器中运行t-sql语句:

select@@identity

其输出值()。

(选择一项)

A.可能为0.1

B.可能为3

C.肯定为0

D.不可能为-100

答案:

b

所在章节:

第三章

提示:

@@identity用于查询最近一次标识列的值

9:

在sqlserver2005中,以下()是t-sql语句的注释符号。

(选择一项)

A.//

B.--

C.///

D.*

答案:

b

所在章节:

第三章

评:

sql中的注释有两种:

--表示单行注释,/*…*/表示多行注释

10:

sqlserver2005中,在存储过程中,()语句用来向用户报告错误,并可指定严重级别。

(选择一项)

A.print

B.error

C.raiseerror

D.raise

答案:

c

所在章节:

第六章

评:

raiserror用来报告错误,raiserror(‘消息’,级别,状态)

11:

在sqlserver2005中,执行以下的t-sql:

begintransaction

ifexists(selecttitle_idfromtitleswheretitle_id='fc2')

  begin

     deletetitleswheretitle_id='tc2'

     rollbacktransaction

     print'ok'

 end

若能找到title_id的tc2的记录,将()。

(选择一项)

A.删除该记录行,不打印任何信息

B.不删除该记录行,并且打印ok

C.删除该记录行,并且打印ok

D.不除该记录行,也不打印任何信息

答案:

b

所在章节:

第五章

提示:

在事务中,rollbacktran用于回滚事务;committran用于提交事务;并且rollbacktran和committran下面的语句同样会执行

12:

在sqlserver2000中,根据以下表设计的代码,判断其设计方面的问题是()。

createtablemember(

   last_namechar(20)null,

   first_namevarchar(30)notnull,

   address_line1varchar(30)null,

   address_line2varchar(30)null,

   address2_line1varchar(30)notnull,

   address2_line2char(30)null,

book_id int  null)  (选择一项)

A.应该把所有的null修改为notnull,而且把notnull修改为null

B.该表有进一步规范化的必要

C.把book_id设为主键

D.所以字段都应允许为空

答案:

b

所在章节:

第一章

提示:

符合1范式,不符合二范式,没有标识列

13:

在sqlserver2000中,在products(产品)表,包含字段:

pname(产品名称)、price(价格)。

若要得到最贵产品的产品名称和产品价格,应该使用的查询语句是()。

(选择一项)

A.selecttop1pname,pricefromproductsorderbyprice

B.selectpname,max(price)fromproducts

C.selectpname,max(price)fromproductsgroupbypname

D.selectpname,pricefromproductswhereprice=(selectmax(price)fromproduct)

答案:

d

所在章节:

第四章

评:

A没有指明排序的方式;

B语法错误,pname应当包含在聚合函数或groupby子句中

C.语法无错,但不符合题意

D.子查询实现

14:

在sqlserver2000数据库中,执行如下的sql语句,将().

print'服务器为:

'+@@servicename

A.在网格窗口以网格的方式显示当前计算机上的sql服务名称

B.在消息窗口以文本的方式显示当前计算机上的sql服务名称

C.在网格窗口以网格的方式显示本地服务名称

D.在消息窗口以文本的方式显示本地服务名称

答案:

b

所在章节:

第三章

提示:

在sql中输出可以使用print或select;

区别在于:

print是消息形式输出,而select是以网格形式输出

@@servicename表示当前计算机上的sql服务名称

15:

在sqlserver2000数据库中,关于视图的说法错误的是()。

A.视图是一个可以虚拟的表,在物理介质上并不存在

B.视图可以查看来自一个或多个表的内存

C.修改了视图的数据,原始数据并不会被修改

D.使用creatview来创建视图

答案:

c

所在章节:

第五章

评:

视图是一张虚表,没有真正的数据,数据来源于基表,视图在满足一定条件时,是可以修改的。

它修改视图就是在修改原表。

16:

sqlserver2000中。

已知有student表,表中共有10条status列值为0的记录。

创建试图。

命令执行的结果是()

createviewview1

 as

select*fromstudentwherestatus=0

视图创建成功后,执行如下命令:

updataview1setstatus=1;

select*fromview1;

A.错误提示:

不能对视图执行更新操作

B.错误提示:

不能对视图执行查询操作

C.返回10条记录

D.返回0条记录

答案:

d

所在章节:

第五章

提示:

修改视图就是在修改原表,视图中的数据都是来自于原表

17:

数据库设计时,在做表规范化的时候一般规范到()就足够了。

(选择一项)

A.第一范式

B.第三范式

C.第四范式

D.第五范式

答案:

  b

所在章节:

第一章

评:

表规范化一般达到3NF

18:

在sqlserver2000中,为数据库表建立索引能够()。

(选择一项)

A.防止非法的删除操作

B.防止非法的插入操作

C.提高查询性能

D.节约数据库的磁盘空间

答案:

  c

所在章节:

第五章

评:

索引的目的就是提高查询的性能

19:

在sqlserver2005中,已知student表中有一个age列,数据类型是int,如果要限制该列的取值范围在15到30之间,可以使用以下sql语句()。

(选择一项)

A.altertablestudentaddcheck(age>=15andage<=30)

B.altertablestudentadddefault(age>=15andage<=30)

C.altertablestudentaddunique(age>=15andage<=30)

D.altertablestudentaddset(age>=15andage<=30)

答案:

a

所在章节:

第二章

评:

check约束

20:

sqlserver2005中,使用t-sql编程时,输出结果有两种方式:

()或()语句。

(选择一项)

A.setselect

B.printselect

C.setmake

D.printset

答案:

  b

所在章节:

第三章

评:

表格输出和文本输出

21:

在sqlserver2005中,给定如下的t-sql:

declare@abcint

declare@xyzint

set@abc=10

while@abc<=100

       begin

               set@xyz=

                casefloor(@abc/30)

 when0then@abc*5

         when1then@abc*10

           else@abc*20

   end

   set@abc=@xyz

end

print@xyz

程序最后输出的结果是()。

(选择一项)

A.50

B.500

C.100

D.以上都不对

答案:

b

所在章节:

第四章

提示:

case…when…then….end类似于普通语言中的switch语句,每次只会执行其中的一种情况

floor()实现的是求小于或等于这个数的最大整数

22:

在sqlserver2005的查询分析器中运行以下的t-sql:

(选择一项) 

selectdistinctt1.typefromtitlest1wheret1.typein

(selecttypefromtitleswheret1.pub_id<>pub_id)

A.查询成功,但是将查询不到任何数据行

B.查询成功,可能能够查询到一行或者多行数据

C.查询失败,因为在同一张表中进行查询和子查询必须使用表的别名

D.查询失败,因为不能同时在一张表中执行多次查询

答案:

b

所在章节:

第四章

评:

distinct是剔除重复行,

查询pub_id不同,type相同的type记录

 

23:

在sqlserver2000中,可以使用全局变量()来获得最后一次插入的标识值。

(选择一项)

A.@@datefirst

B.@@identity

C.@@transcount

D.@@rowcount

答案:

b

所在章节:

第三章

评:

@@identity用来获得最后一次插入的标识值

24:

sqlserver2005中,在查询分析器中调用()系统存储过程可以修改数据库的名称。

(选择一项)

A.sp_databases

B.sp_renamebd

C.sp_tables

D.sp_rename

答案:

b

所在章节:

第六章

评:

sp_databases列出所有的数据库

Sp_renamedb重命名数据库

Sp_tables查询当前数据库下的所有的表和视图

Sp_rename在当前数据库中更改用户创建对象的名称

25:

在sqlserver2000数据库中,表stuinfo的属性列stuaddress表示学生居住地址,对stuaddress添加了如下的约束,其意义是()。

(选择一项)

altertablestuinfo

addconstraintdfsinaddressdefault(‘待定不详’)forstuaddress

A.stuaddress列不允许为空,已经存在的记录,如果该列为空,则自动填写“待定不详”

B.添加新记录时,如果stuaddress列不填,默认填写“待定不详”

C.stuaddress列全部修改填写为“待定不详”

D.将stuaddress列值为“待定不详”的记录全部划为非法,予以删除

答案:

b

所在章节:

第二章

评:

默认约束

26:

在sqlserver2005数据库中,表student中有字段stuname和stuage,与如下语句等值的sql语句为()。

假设表中姓名列可以有重复的值.

declare@ageint

select@age=stuagefromstudentwherestuname='杨超'

select*fromstudentwherestuage=@age   (选择一项)       

A.select*fromstudentwherestuname=‘杨超’adnstuage=(selectstuagefromstudentwherestuname=‘杨超’)

B.select*fromstudentwherestuage=(selectstuagefromstudentwherestuname=‘杨超’)

C.select*fromstudentwherestuagein(selectstuagefromstudentwherestuname=‘杨超’)

D.declare@ageint

selec*fromstudentwherestuage=(select@age=stuagefromstudentwherestuname=‘杨超’)

答案:

c

所在章节:

第三章

评:

查询跟‘杨超’同龄的学生的所有信息,’=’只有一个结果,in匹配多个结果,‘杨超’可能有多个,所以用in

27:

在sqlserver2005中,以下是表autos的定义:

createtableautos(makevarchar(20)notnull,modelvarchar(20)notnull,

           acquisition_costmoneynull,acquisition_datedatetimenull)

创建该表后再执行以下语句:

truncatetableautos

begintran

insertautos(make,model)values('tucker','torpedo')

ifexists(select*fromautos)

        rollbacktran

else

       committran

执行结果是()。

(选择一项)

A.该批处理将失败,因为begintran…committran没有正确嵌套

B.该批处理结束后,表内没有数据行

C.该批处理结束后,表内有一行数据

D.插入数据行的语句将失败,并且提示错误信息

答案:

b

所在章节:

第五章

提示:

insert语句用于向表中增加数据,但是ifexists语句用于查看表中是否有值,如果有,那么回滚,此时回滚会将事务中所有做的操作回滚,所以最后表中没有数据.

28:

在sqlserver2005中,创建视图view_b的代码为()。

(选择一项)

A.createviewview_basselect*fromtable_a

B.createview_basselect*fromtable_a

C.createviewview_bforselect*fromtable_a

D.createview_bforselect*fromtable_a

答案:

b

所在章节:

第五章

评:

创建视图的语法:

createview视图名assql语句

29:

在sqlserver2005中,从product表里查询出price(价格)高于pname(产品名称)为“一次性纸杯”的所有记录,此sql语句为()。

(选择一项)

A.select*fromproductwheremax(price)>'一次性纸杯'

B.select*fromproductwhereprice>(selectmax(*)fromproductwherepname='一次性纸杯')

C.select*fromproductwhereexistspname='一次性纸杯'

D.select*fromproductwhereprice>(selectmax(price)fromproductwherepname='一次性纸杯')

答案:

d

所在章节:

第四章

评:

子查询要查询出’一次性子杯’产品的最高价格,然后再实现外查询

30:

在sqlserver2005中,要创建一个product(产品)表,包括三个字段:

pid(编号)int,pname(名称)char(20),qty(数量)int要求:

pid设为标示列,列值从1开始,每次自动加1:

产品的数量应总是正的值。

下列sql语句能满足上述条件的是()。

(选择一项)

A.createtableproduct(pidintidentiy(1,1),pnamechar(20)notnull,qtyintnotnullconstraintchkqtycheck(qty>0))

B.createtableproduct(pidintnotnullconstraindefproductiddefault1,pnamechar(20)notnull,qtyintnotnullconstraintchkqtycheck(qty>0))

C.createtableproduct(pidintidentiy(1,1),pnamechar(20)notnull,qtyintnotnullconstraintchkqtyunique(qty>0))

D.createtableproduct(pidintnotnullconstraindefproductiddefault1,pnamechar(20)notnull,qtyintnotconstraintchkqtyunique(qty>0))

答案:

a

所在章节:

第二章

评:

标识列是identity(),检查约束是check

31:

在sqlserver2005中,与下列t-sql语句等效的语句为()。

(选择一项)

updateaseta1=a1*2wherea2in(selecta2frombwhereb1=2)

A.updateaseta1=a1*2innerjoinbonb.b1=2

B.updateaseta1=a1*2fromainnerjoinbonb.b1=2

C.updateaseta1=a1*2whereainnerjoinbona.a2=b.a2andb.b1=2

D.updateaseta1=a1*2fromainnerjoinbona.a2=b.a2andb.b1=2

答案:

d

所在章节:

第四章

评:

子查询与连接查询的转换

32:

在sqlserver2000中,声明一个最多可以存储5个字符的变量a,正确的代码是()。

(选择一项)

A.declareavarchar(5)

B.declare@avarchar(5)

C.avarchar(5)

D.@avarchar(5)

答案:

b

所在章节:

第三章

提示:

在sql中变量的定义方式:

declare@变量名数据类型

33:

在sqlserver的安全管理过程中,以下()的概念类似于windows中的用户。

(选择一项)

A.权限

B.登录帐户

C.角色

D.存储过程

答案:

b

所在章节:

第二章

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1