sql复习资料2.doc_第1页
sql复习资料2.doc_第2页
sql复习资料2.doc_第3页
sql复习资料2.doc_第4页
sql复习资料2.doc_第5页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

一、选择题1、现有表名称为score,有一个名称为teacher的用户名。要求授予表的插入和修改的权限,正确的授权语句是( )。(选择一项)A、grant insert,update to table score on teacher B、grant insert and update to table score on teacher C、grant insert,update on score to teacher D、grant insert and update on score to teacher2、在SQL Server 2005中,现有orders(订单)表,包含字段:cid(顾客编号),pid(产品编号)。若查询既订购了产品P01,又订购了产品P02的顾客编号,可以执行以下()sql语句。 (选择二项)A.select distinct(cid) from orders o1 where o1.pid in (p01,p02)B.select distinct(cid) from orders o1,orders o2 where o1.pid=p01 and o2.pid=p02and o1.cid=o2.cidC.select distinct(cid) from orders o1 where pid=po1 and cid in (select cid from orders where pid=po2)D.select distinct(cid)from orders o1,orderso2 where o1.pid=po1 and o2.pid=po23、在sql server2005中,在products(产品)表,包含字段:pname(产品名称)、price(价格)。若要得到最贵产品的产品名称和产品价格,应该使用的查询语句是( )。(选择一项)A、select top 1 pname,price from products order by price B、select pname,max(price) from products C、select pname,max(price) from products group by pname D、select pname,price from products where price = (select max(price) from product)4、在sql server2005中给定如下的t-sql代码,以下说法正确的是()。(选择一项)create procedure price_proc(count int output,avg_price money output,type char(12)=business)asselect count=count(*),avg_price=avg(price) from titles where type=typeA、建立一个存储过程price_proc,所有参数都是输出参数B、建立一个存储过程price_proc,返回的是用户指定图书种类的数量及平均价格C、count=count(*)也可以用count=count()代替D、创建存储过程失败,因为select语句中使用了聚合函数,因此必须使用group by进行分组5、现有一个学生信息表student,包含主键studentID (学生编号)。又有分数表scores,包含studentID(学生编号)、以及 score(考试分数)。已知student表中共有50个学生,有45人参加了考试(分数存在scores表中),其中10人不及格。执行以下sql语句:select * from student where exists (select studentid from score where score60)可返回()条记录。(选择一项)A.50B.45C.10D.06、在某个触发器中,存在如下代码片断:Declare p1 int, p2 intSelect p1=price from deletedSelect p2=price from insertedprint convert(varchar, p2-p1)该触发器是()触发器。A.selectB.updateC.insertD.delete7、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表中存在()行记录。A.1B.2C.3D.48、在sql server 2005中,创建存储过程如下,要在students表中查找age(年龄)是18岁的学生,( )可以正确的调用这个存储过程。(选择二项)create procedure myp1 p int asselect studentname,age from students where age = pA、exec myp1 18 B、exec myp1 p=18 C、exec myp1 p=18 D、exec myp1 p=189、已知有如下功能:create proc proc_testtable_name varchar(20)asdeclare sql varchar(100)select sql = select * from +table_nameexec (sql)go请问以上语句的运行结果是( )(选择二项)A、此存储过程有错,不能执行B、此存储过程会打印输出一条sql语句C、这是属于exec的另一种用法,用于执行一条sql语句D、它执行的结果是查询到用户输入表中的所有信息10、事务的特性有( )(选择四项)A、原子性 B、一致性 C、隔离性 D、持久性 E、不变性11、合并多个表中的数据的方法有( )三种(选择三项)A、联合 B、子查询 C、联接 D、角色12、事务的分类分为( )(选择三项)A、显式事务 B、隐式事务 C、自动提交事务 D、隐式提交事务13、在SQL Server2005的查询分析器中运行以下T-SQL,将打印输出( )。(选择一项)CREATE TABLE My_Table(a int NULL,b int NULL)GO CREATE TRIGGER my_trig ON My_Table FOR INSERTAS IF UPDATE(b) PRINT更新GO INSERT My_TableVALUES(3,4)GO UPDATE My_Table SET a = 5 WHERE b = 4GOA、更新B、更新 更新C、不打印任何信息 D、以上代码将出现运行错误而中断14、假设orders表中存在oid等于1的记录,执行下面T-SQL:BEGIN TRANSACTIONDelete from Orders where oid=1IF (Error0)ROLLBACK TRANSACTIONElseCOMMIT TRANSACTION以下说法正确的是( )。(选择一项)A、执行成功,oid为1的记录被永久删除 B、执行成功,Orders表没有任何变化C、执行时出现错误 D、执行成功,但事务处理并没有结束15、Sql server2005中,创建触发器的语句如下:create trigger trig_score on score for insert asdeclare sid int , score floatselect sid = sid,score =score from insertedupdata student set score = score+score where sid = sidGo其中score表通过sid列与student 表建立了外键约束,假定数据库中的数据具备完整性,创建触发器成功后,执行语句:insert into scroe (sid ,scroe)values(2,20),执行后的结果是( )(选择一项)A、Score表中插入一条数据,student表中更新一条数据B、Score表中插入一条数据,student表中插入一条数据C、Score表中插入一条数据,student表中没有变化D、提示错误:没有inserted这张表16、在SQL Server 2005中,触发器包含许多功能,除了( )。(选择一项)A、强化约束 B、可级联运行 C、跟踪变化 D、查询优化17、在SQL Server中,( )返回受上一语句影响的行数。(选择一项)A、count B、rowcount C、row D、dentity18、下列不属于触发器动作的是( )。(选择一项)A、select B、insert C、update D、delete19、在SQL Server中,存储过程分为( )类(选择一项)A、系统存储过程 B、扩展存储过程 C、用户自定义存储过程 D、以上都是20、在SQL Server 2005中,以下SQL语句能正确创建主键的有( )。(选择二项)A、create table mytable(id int primary key,name varchar(20)B、create table mytable(primary key id int,name varchar(20)C、create table mytable(id int null,name varchar(20),primary key(id)D、create table mytable(id int,name varchar(20),constraint PK_mytable primary key(id)21. Sql server 2000中,已知执行语句:select count(score),sum(score) from score返回的结果是10和750,那么执行语句:select avg(score) from score,返回的结果是()。(选择一项)A.10B.75C.750D.750022. 在SQL Server 2000中,与下列T-SQL语句等效的语句为()。(选择一项)UPDATE A SET A1=A1*2 WHERE A2 IN(SELECT A2 FROM B WHERE B1=2)A.UPDATE A SET A1=A1*2 INNER JOIN B ON B.B1=2B.UPDATE A SET A1=A1*2 FROM A INNER JOIN B ON B.B1=2C.UPDATE A SET A1=A1*2 WHERE A INNER JOIN B ON A.A2=B.A2 AND B.B1=2D.UPDATE A SET A1=A1*2 FROM A INNER JOIN B ON A.A2=B.A2 AND B.B1=223. 在SQLServer 2005中,从product表里查询出price(价格)高于pName(产品名称)为“一次性纸杯”的所有记录,此SQL语句为()。(选择一项)A.SELECT* FROM product WHERE max(price)一次性纸杯B.SELECT* FROM product WHERE price(SELECT max(*) FROM product WHERE pName=一次性纸杯);C.SELECT* FROM product WHERE EXISTS pName=一次性纸杯D.SELECT* FROM product WHERE price(SELECT max(price) FROM product WHERE pName=一次性纸杯);24. Sql server 2005中,在查询分析器中调用()系统存储过程可以修改数据库的名称。(选择一项)A.sp_databasesB.sp_renamebdC.sp_tablesD.sp_rename25. 在SQL Server 2005中,给定如下的T-SQL:declare abc intdeclare xyz intSet abc=10while abc=100 begin set xyz= case floor(abc/30) when 0 then abc*5 when 1 then abc*10 else abc*20 end set abc=xyz endprint xyz程序最后输出的结果是()。(选择一项)A.50B.500C.100D.以上都不对26.SQL Server

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论