SQL Server 2005面试笔试题与答案.docx_第1页
SQL Server 2005面试笔试题与答案.docx_第2页
SQL Server 2005面试笔试题与答案.docx_第3页
SQL Server 2005面试笔试题与答案.docx_第4页
SQL Server 2005面试笔试题与答案.docx_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

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

文档简介

SQL Server 2005考试题考试时间90分钟一、选择题(26-30每题2分,其余1分 共45分)1)假定有一个用户表,表中包含字段:userid (int)、username (varchar)、 password(varchar)、等,该表需要设置主键,以下说法正确的是(AB)。(选择两项) a)如果不能有同时重复的username和password,那么username和password可以组合在一起作为主键。 b)此表设计主键时,根据选择主键的最小性原则,最好采用userid作为主键。 c)此表设计主键时,根据选择主键的最小性原则,最好采用username和password作为组合键。 d) 如果采用userid作为主键,那么在userid列输入的数值,允许为空。 2)Microsoft SQL Server 2000 在安装的时候就创建的示例用户数据库包括(AC)。(选择两项) a)Pubs b)Master c)Northwind d)Msdb3)以下(B)语句从表TABLE_NAME中提取前10条记录。(选择一项) a)select * from TABLE_NAME where rowcount=10 b)select TOP 10 * from TABLE_NAME c)select TOP of 10 * from TABLE_NAME d)select * from TABLE_NAME where rowcount一次性纸杯 b)SELECT * FROM 产品WHERE 价格(SELECT * FROM 产品WHERE 产品名称 一次性纸杯 c)SELECT * FROM 产品WHERE EXISTS 产品名称= 一次性纸杯 d)SELECT * FROM 产品WHERE 价格(SELECT 价格FROM 产品WHERE 产品名称= 一次性纸杯 5)查找 student表中所有电话号码(列名:telephone)的第一位为8或6,第三位为0的电话号码(C)。(选择一项) a)SELECT telephone FROM student WHERE telephone LIKE 8,6%0* b)SELECT telephone FROM student WHERE telephone LIKE (8,6)*0% c)SELECT telephone FROM student WHERE telephone LIKE 8,6_0% d)SELECT telephone FROM student WHERE telephone LIKE 8,6_0* 6)现有表book,字段:id (int),title (varchar), price (float); 其中id字段设为标识, 使用insert语句向book表中插入数据,以下语句错误的是(A)。(选择一项) a)insert into book (id,title,price) values(1,java,100) b)insert into book (title,price) values(java,100) c)insert into book values (java,100) d)insert book values(java,100) 7)现有表Employee,字段:id (int),firstname(varchar), lastname(varchar); 以下sql语句错误的是(B)。(选择一项) a)select firstname+.+lastname as name from employee ) b)select firstname+.+lastname=name from employee c)select name=firstname+.+lastname from employee d)select firstname,lastname from employee 8)在sql server 2000中,关于数据库说法错误的是(C)。(选择一项) a)数据库在磁盘上默认的存储位置是:SQL Server安装路径Microsoft SQL ServerMSSQLData b)一个数据库至少应包含一个数据库文件(*.mdf)和一个事务日志文件(*.ldf) c)只有当数据库中不存在数据的情况下,才可以进行数据库的收缩操作。 d)可以通过从A机器拷贝数据库文件和事务日志文件至B机器,然后通过在B机器上执行相应的附加数据库操作,实现数据库从A机器到B机器的复制。9)若要删除book表中所有数据,以下语句错误的是(BC)。(选择两项) a)truncate table book /对整个数据表中的数据进行删除,没有附带事物这一特性,比delete要快,只能删除单表中的数据 b)delete * from book c)drop table book /删除整个数据表对象 d)delete from book 10)学生成绩表grade中有字段score(float),现在要把所有在55分至60之间的分数提高5分,以下sql语句正确的是(CD)。(选择两项) a)Update grade set score=score+5 b)Update grade set score=score+5 where score=55 or score =55 and score =6011)现有书目表book,包含字段:price (float); 现在查询一条书价最高的书目的详细信息,以下语句正确的是(BC)。(选择两项) a)select top 1 * from book order by price asc b)select top 1 * from book order by price desc c)select top 1 * from book where price= (select max (price)from book) d)select top 1 * from book where price= max(price)/聚合函数只能放在select 和from 之间使用12)现有书目表book,包含字段:价格price (float),类别type(char); 现在查询各个类别的平均价格、类别名称,以下语句正确的是(A)。(选择一项) a)select avg(price),type from book group by type b)select count(price),type from book group by price c)select avg(price),type from book group by price d)select count (price),type from book group by type 13)查询student表中的所有非空email信息, 以下语句正确的是(D)。(选择一项) a)Select email from student where email !=null b)Select email from student where email not is null c)Select email from student where email null d)Select email from student where email is not null 14)成绩表grade中字段score代表分数,以下(BC)语句返回成绩表中的最低分。(选择两项) a)select max(score) from grade b)select top 1 score from grade order by score asc c)Select min(score) from grade d)select top 1 score from grade order by score desc 15)现有订单表orders,包含用户信息userid, 产品信息 productid, 以下(D)语句能够返回至少被订购过两回的productid? (选择一项) a)select productid from orders where count(productid)1 b)select productid from orders where max(productid)1 c)select productid from orders where having count(productid)1 group by productid_ d)select productid from orders group by productid having count(productid)1 16)关于聚合函数,以下说法错误的是(B)。(选择一项) a)Sum返回表达式中所有数的总合,因此只能用于数字类型的列。 b)Avg返回表达式中所有数的平均值,可以用于数字型和日期型的列。 c)Max和Min可以用于字符型的列。 d)Count可以用于字符型的列。17)使用以下(B)不可以进行模糊查询。(选择一项) a)OR b)Not between c)Not IN d)Like18)关于多表联接查询,以下(B)描述是错误的。(选择一项) a)外联接查询返回的结果集行数可能大于所有符合联接条件的结果集行数。 b)多表联接查询必须使用到JOIN关键字 c)内联接查询返回的结果是:所有符合联接条件的数据。 d)在where子句中指定联接条件可以实现内联接查询。19)Sql语句:select * from students where SNO like 0100%A,B,C%,可能会查询出的SNO是(AD)。(选择两项) a)01053090A #Hm3? /0 表示不可以为0 b)01003090A01 c)01053090D09 d)0101A0120)关于Truncate table, 以下(AD)描述是错误的。(选择两项) a)Truncate table 可跟Where从句,根据条件进行删除。 b)Truncate table 用来删除表中所有数据。 c)触发器对Truncate table无效。 d)delete 比Truncate table速度快。 21)创建一个名为Customers的新表,同时要求新表中包含表clients的所有记录,sql语句是(A)。(选择一项) a)Select * into customers from clients b)Select into customers from clients c)Insert into customers select * from clients d)Insert customers select * from clients22)关于主键,以下(BD)说法是错误的。(选择两项) a)主键可以用来确保表中不存在重复的数据行。 b)一个表必须有一个主键。 c)一个表只能有一个主键。 d)只能对整数型列设置主键。23)假设订单表orders用来存储订单信息,cid代表客户编号,money代表单次订购额,现要查询每个客户的订购次数和每个客户的订购总金额,下面(D)sql语句可以返回正确结果。(选择一项) a)select cid,count(distinct(cid),sum(money) from orders group by cid b)select cid,count(distinct(cid),sum(money) from orders order by cid c)select cid,count(cid),sum(money) from orders order by cid d)select cid,count(cid),sum(money) from orders group by cid 24)现有客户表customers(主键:客户编号cid),包含10行数据,订单表orders(外键:客户编号cid),包含6条数据。执行sql语句:select * from customers right outer join orders on customers.cid=orders.cid。最多返回(B)条记录。(选择一项) a)10 b)6 /右外链接即显示outer join 右边的表的数据 c)4 d)0 25)以下描述不正确的是 (D) a)存储过程能够实现较快的执行速度。 b)内嵌表值型函数相当于一个带参数的视图。 c)不指定所有者时,调用标量函数会出错。 d)可以通过视图更改任意基表26)Your database stores telephone numbers. Each telephone number is stored as an integer. You must format the telephone number to print on a report in the following format:(999) 999-9999You have selected the phone number into a local variable as follows:DECLARE PhoneNumber intWhich statement will correctly format the number? (D) a)SELECT Phone Number = ( + SUBSTRING(CONVERT(varchar(10), PhoneNumber),3,0) + ) + SUBSTRING(CONVERT(varchar(10), PhoneNurnber),3,3)+ - + SUBSTRING(CONVERT(varchar(10), PhoneNumber),4,6) b)SELECT Phone Number = ( + SUBSTRING(CONVERT(varchar(10),PhoneNuwber),3,1) + ) + SUBSTRING(CONVERT(varcher(10), PhoneNumber),3,4)+ - + SUBSTRING(CONVERT(varchar(10), PhoneMumber),4,7) c)SELECT Phone Number = ( + SUBSTRING(CONVERT(varchar(10), PhoneNumber),0,3) + ) + SUBSTRING(CONVERT(varchar(10), PhoneNumber),3,3)+ - + SUBSTRING(CONVERT(varchar(10), PhoneNurtiber),6,4) d)SELECT Phone Number = ( + SUBSTRING(CONVERT(varchar(10), PhoneNumber),1,3) + ) + SUBSTRING(CONVERT(varchar(10), PhoneNumber),4,3)+ - + SUBSTRING(CONVERT(varchar(10), PhoneNumber),7,4)27)You are a database developer for Wide World Importers. You are creating a database that will store order information. Orders will be entered in a client/server application. Each time a new order is entered, a unique order number must be assigned. Order numbers must be assigned in ascending order. An average of 10,000 orders will be entered each day. You create a new table named Orders and add an OrderNumber column to this table. What should you do next? (B) a)Set the data type of the column to UniqueIdentifier. b)Set the data type of the column to int, and set the IDENTITY property for the column. c)Set the data type of the column to int. Create a user-defined function that selects the maximum order number in the table. d)Set the data type of the column to int. Create a NextKey table, and add a NextOrder column to the table. Set the data type of the NextOrder column to int. Create a stored procedure to retrieve and update the value held in the NextKey.28)You are creating a script that will execute this stored procedure. If the stored procedure executes successfully, it should report the year-to-date sales for the book title. If the stored procedure fails to execute, it should report the following message:“No Sales Found”How should you create the script?(D) a)DECLARE retval int DECLARE ytd int EXEC get_sales_for_title Net Etiquette, ytd IF retval 0 PRINT No sales found ELSE PRINT Year to date sales: + STR (ytd) GO b)DECLARE retval int DECLARE ytd int EXEC get_sales_for_title Net Etiquette, ytd OUTPUT IF retval 0 PRINT No sales found ELSE PRINT Year to date sales: + STR (ytd) GO c)DECLARE retval int DECLARE ytd int EXEC get_sales_for_title Net Etiquette,retval OUTPUT IF retval 0 PRINT No sales found ELSE PRINT Year to date sales: + STR (ytd) GO d)DECLARE retval int DECLARE ytd int EXEC retval = get_sales_for_title Net Etiquette, ytd OUTPUT IF retval 1250 命令的功能是(D )。A.查询工资大于1250的纪录B.查询1250号记录后的记录C.检索所有的职工号D.从职工关系中检索工资大于1250的职工号40)关于关系图下列哪一个是正确的( C)。A.关系图是在同一个表中不同字段之间建立关联B.关系图是表与表之间建立关联,与字段无关C.关系图是在不同表中的字段之间建立关联D.关系图是在不同数据库之间建立关联二、判断题:(每小题1分,共20分)1. ODBC是由Microsoft定义的一种数据库访问标准。(T )2. 信息和数据是相对的,有时是可以互相转换的。( T)3. 创建存储过程必须在企业管理器中进行。( F)4. 触发器主要是通过表操作事件进行触发而被执行的。(T )5. 主键字段允许为空。( F)6. SQL Server 自动为primary key约束的列建立一个索引。(T )7. SQL Server的数据库可以转换成Access数据库。(T )8. 删除表时,表中的触发器被同时删除。(F )9. 数据库的名称一旦建立就不能重命名。( F)10. 固定数据库角色:db_datarader 的成员可修改本数据库内表中的数据。( F)11. 安装Microsoft SQL Server 2005 企业版对操作系统的最低要求可以是Microsoft Windows 2000 Professional。( F)/只能装在服务器server版本上12. 每一个服务器必须属于一个服务器组。一个服务器组可以包含0个、一个或多个服务器。( T)13. 验证模式是在安装SQL Server过程中选择的。系统安装之后,可以重新修改SQL Server系统的验证模式。(T )14. 固定数据库角色:db_datareader 的成员不能修改本数据库内表中的数据。( T)15. 当用户定义的数据类型正在被某个表的定义引用时,这些数据类型不能被删除。(T )16. 在使用子查询时,必须使用括号把子查询括起来,以便区分外查询和子查询。( T)17. 索引越多越好。( F)18. 视图本身不保存数据,因为视图是一个虚拟的表。( T)19. 创建触发器的时候可以不是表的所有者或数据库的所有者。( T)20. select 16%4, 的执行结果是: 4 吗? ( F)三、阅读下列程序,说明它们的功能。(每题4分,共20分)1use 成绩数据库If exists ( select name from sysobjectsWhere name=student_inf and type=p)Drop procedure student_infGoCreate procedure student_info asSelect 学号, 姓名, 总学分 from xsqk2use 成绩数据库CREATE TRIGGER abc ON dbo.XSCJ FOR UPDATE ASif update(

温馨提示

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

评论

0/150

提交评论