SQLSERVER内部测试文档格式.docx
《SQLSERVER内部测试文档格式.docx》由会员分享,可在线阅读,更多相关《SQLSERVER内部测试文档格式.docx(23页珍藏版)》请在冰点文库上搜索。
C.alter
D.for
6.在sqlserver2005中,对存储过程的描述中正确的是()。
A.定义了一个有相关列和行的集合
B.它根据一列或多列的值,提供对数据库表的行的快速访问
C.当用户修改数据时,一种特殊形式的存储过程被自动执行
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
8.在sqlserver查询分析器中运行t-sql语句:
select@@identity
其输出值()。
A.A.可能为0.1
B.B.可能为3
C.C.肯定为0
D.D.不可能为-100
9.在sqlserver2005中,以下()是t-sql语句的注释符号。
A.//
B.--
C.///
D.*
10.sqlserver2005中,在存储过程中,()语句用来向用户报告错误,并可指定严重级别。
A.print
B.error
C.raiserror
D.raise
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.不除该记录行,也不打印任何信息
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_idintnull)(选择一项)
A.应该把所有的null修改为notnull,而且把notnull修改为null
B.该表有进一步规范化的必要
C.把book_id设为主键
D.所以字段都应允许为空
13.在sqlserver2000中,在products(产品)表,包含字段:
pname(产品名称)、price(价格)。
若要得到最贵产品的产品名称和产品价格,应该使用的查询语句是()。
A.A.selecttop1pname,pricefromproductsorderbyprice
B.B.selectpname,max(price)fromproducts
C.C.selectpname,max(price)fromproductsgroupbypname
D.D.selectpname,pricefromproductswhereprice=(selectmax(price)fromproduct)
14.在sqlserver2000数据库中,执行如下的sql语句,将().
print'
服务器为:
'
+@@servicename
A.A.在网格窗口以网格的方式显示当前计算机上的sql服务名称
B.B.在消息窗口以文本的方式显示当前计算机上的sql服务名称
C.C.在网格窗口以网格的方式显示本地服务名称
D.D.在消息窗口以文本的方式显示本地服务名称
15.在sqlserver2000数据库中,关于视图的说法错误的是()。
A.A.视图是一个可以虚拟的表,在物理介质上并不存在
B.B.视图可以查看来自一个或多个表的内存
C.C.修改了视图的数据,原始数据并不会被修改
D.D.使用creatview来创建视图
16.sqlserver2000中。
已知有student表,表中共有10条status列值为0的记录。
创建试图。
命令执行的结果是()
createviewview1
as
select*fromstudentwherestatus=0
视图创建成功后,执行如下命令:
updataview1setstatus=1;
select*fromview1;
A.A.错误提示:
不能对视图执行更新操作
B.B.错误提示:
不能对视图执行查询操作
C.C.返回10条记录
D.D.返回0条记录
17.数据库设计时,在做表规范化的时候一般规范到()就足够了。
A.第一范式
B.第三范式
C.第四范式
D.第五范式
18.在sqlserver2000中,为数据库表建立索引能够()。
A.防止非法的删除操作
B.防止非法的插入操作
C.提高查询性能
D.节约数据库的磁盘空间
19.在sqlserver2005中,已知student表中有一个age列,数据类型是int,如果要限制该列的取值范围在15到30之间,可以使用以下sql<
SPA
A.altertablestudentaddcheck(age>
=15andage<
=30)
B.altertablestudentadddefault(age>
C.altertablestudentaddunique(age>
D.altertablestudentaddset(age>
20.sqlserver2005中,使用t-sql编程时,输出结果有两种方式:
()或()语句。
21.在sqlserver2005中,给定如下的t-sql:
declare@abcint
declare@xyzint
set@abc=10
while@abc<
=100
set@xyz=
casefloor(@abc/30)
when0then@abc*5
when1then@abc*10
else@abc*20
set@abc=@xyz
end
print@xyz
程序最后输出的结果是()。
A.50
B.500
C.100
D.以上都不对
22.在sqlserver2005的查询分析器中运行以下的t-sql:
(选择一项)
selectdistinctt1.typefromtitlest1wheret1.typein
(selecttypefromtitleswheret1.pub_id<
>
pub_id)
A.查询成功,但是将查询不到任何数据行
B.查询成功,可能能够查询到一行或者多行数据
C.查询失败,因为在同一张表中进行查询和子查询必须使用表的别名
D.查询失败,因为不能同时在一张表中执行多次查询
23.在sqlserver2000中,可以使用全局变量()来获得最后一次插入的标识值。
A.@@datefirst
B.@@identity
C.@@transcount
D.@@rowcount
24.sqlserver2005中,在查询分析器中调用()系统存储过程可以修改数据库的名称。
A.sp_databases
B.sp_renamedb
C.sp_tables
D.sp_rename
25.在sqlserver2000数据库中,表stuinfo的属性列stuaddress表示学生居住地址,对stuaddress添加了如下的约束,其意义是()。
altertablestuinfo
addconstraintdf_sinaddressdefault(‘待定不详’)forstuaddress
A.stuaddress列不允许为空,已经存在的记录,如果该列为空,则自动填写“待定不详”
B.添加新记录时,如果stuaddress列不填,默认填写“待定不详”
C.stuaddress列全部修改填写为“待定不详”
D.将stuaddress列值为“待定不详”的记录全部划为非法,予以删除
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
select*fromstudentwherestuage=(select@age=stuagefromstudentwherestuname=‘杨超’)
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.插入数据行的语句将失败,并且提示错误信息
28.在sqlserver2005中,创建视图view_b的代码为()。
A.createviewview_basselect*fromtable_a
B.createview_basselect*fromtable_a
C.createviewview_bforselect*fromtable_a
D.createview_bforselect*fromtable_a
29.在sqlserver2005中,从product表里查询出price(价格)高于pname(产品名称)为“一次性纸杯”的所有记录,此sql语句为()。
A.select*fromproductwheremax(price)>
一次性纸杯'
B.select*fromproductwhereprice>
(selectmax(*)fromproductwherepname='
C.select*fromproductwhereexistspname='
D.select*fromproductwhereprice>
(selectmax(price)fromproductwherepname='
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>
C.createtableproduct(pidintidentiy(1,1),pnamechar(20)notnull,qtyintnotnullconstraintchkqtyunique(qty>
D.createtableproduct(pidintnotnullconstraindefproductiddefault1,pnamechar(20)notnull,qtyintnotconstraintchkqtyunique(qty>
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
32.在sqlserver2000中,声明一个最多可以存储5个字符的变量a,正确的代码是()。
A.declareavarchar(5)
B.declare@avarchar(5)
C.avarchar(5)
D.@avarchar(5)
33.在sqlserver的安全管理过程中,以下()的概念类似于windows中的用户。
A.权限
B.登录帐户
C.角色
D.存储过程
34.sqlserver2005中,已知执行语句:
selectcount(score),sum(score)fromscore返回的结果是10和750,那么执行语句:
selectavg(score)fromscore,返回的结果是()。
A.10
B.75
C.750
D.7500
35.在sqlserver2005中,与以下t-sql等效的是()。
updatetitlesssetprice=price*1.05wherepub_idin(selectpub_idfrompublishers)
A.updatetitlessetprice=price*1.05whereexists(selectpub_idfrompublishers)
B.updatetitlessetprice=price*1.05fromtitleswherepub_idinpublishers.pub_id
C.updatetitlessetprice=price*1.05wheretitles.pub_id=publishers.pub_id
D.updatetitlessetprice=price*1.05formtitlesinnerjoinpublishersontitles.pub_id=publishers.pub_id
36.在sqlserver2000中给定如下的t-sql代码,以下说法正确的是()。
createprocedureprice_proc
(@countintoutput,@avg_pricemoneyoutput,@typechar(12)='
business'
select@count=count(*),@avg_price=avg(price)fromtitleswheretype=@type
A.建立一个存储过程price_proc,所有参数都是输出参数
B.建立一个存储过程price_proc,返回的是用户指定图书种类的数量及平均价格
C.@count=count(*)也可以用@count=count()代替
D.创建存储过程失败,因为select语句中使用了聚合函数,因此必须使用groupby进行分组
37.现有表名称为score,有一个名称为teacher的用户名。
要求授予表的插入和修改的权限,正确的授权语句是()。
A.grantinsert,updatetotablescoreonteacher
B.grantinsertandupdatetotablescoreonteacher
C.grantinsert,updateonscoretoteacher
D.grantinsertandupdateonscoretoteacher
38.已知有student表,studentid为主键,现在表中共有10行记录,studentid列值从1到10。
创建视图:
createviewdbo.view_studentasselect*fromdbo.student接着执行如下命令:
deletefromview_studentwhere(studentid=8);
然后执行查询命令:
select*fromstudent;
select*fromview_student;
假定上述命令全部执行成功,将各自返回()()行记录。
A.10,10
B.10,9
C.9,10
D.9,9
39.sqlserver数据库中,包含两个表:
order订单表,item订单子项目表。
当一个新定单被加入时,数据要分别保存到o