A.altertablestudentaddcheck(age>=15andage<=30)
B.altertablestudentadddefault(age>=15andage<=30)
C.altertablestudentaddunique(age>=15andage<=30)
D.altertablestudentaddset(age>=15andage<=30)
20.sqlserver2005中,使用t-sql编程时,输出结果有两种方式:
()或()语句。
(选择一项)
A.setselect
B.printselect
C.setmake
D.printset
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.以上都不对
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>0))
C.createtableproduct(pidintidentiy(1,1),pnamechar(20)notnull,qtyintnotnullconstraintchkqtyunique(qty>0))
D.createtableproduct(pidintnotnullconstraindefproductiddefault1,pnamechar(20)notnull,qtyintnotconstraintchkqtyunique(qty>0))
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')
as
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