设为首页 收藏本站
查看: 632|回复: 0

[经验分享] sql server考试题

[复制链接]

尚未签到

发表于 2018-10-12 10:23:27 | 显示全部楼层 |阅读模式
  一、选择题(1-25没题1分26-30每题2分共35分)
  1)假定有一个用户表,表中包含字段:userid (int)、username (varchar)、 password(varchar)、等,该表需要设置主键,以下说法正确的是()。(选择两项)
  a)如果不能有同时重复的username和password,那么username和password可以组合在一起作为主键。
  b)此表设计主键时,根据选择主键的最小性原则,最好采用userid作为主键。
  c)此表设计主键时,根据选择主键的最小性原则,最好采用username和password作为组合键。
  d) 如果采用userid作为主键,那么在userid列输入的数值,允许为空。
  2)Microsoft SQL Server 2000 在安装的时候就创建的示例用户数据库包括()。(选择两项)
  a)Pubs
  b)Master
  c)Northwind
  d)Msdb
  3)以下()语句从表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的电话号码()。(选择一项)
  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)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语句错误的是()。(选择一项)
  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中,关于数据库说法错误的是()。(选择一项)
  a)数据库在磁盘上默认的存储位置是:SQL Server安装路径/Microsoft SQL Server/MSSQL/Data
  b)一个数据库至少应包含一个数据库文件(.mdf)和一个事务日志文件(.ldf)
  c)只有当数据库中不存在数据的情况下,才可以进行数据库的收缩操作。
  d)可以通过从A机器拷贝数据库文件和事务日志文件至B机器,然后通过在B机器上执行相应的附加数据库操作,实现数据库从A机器到B机器的复制。
  9)若要删除book表中所有数据,以下语句错误的是()。(选择两项)
  a)truncate table book
  b)delete * from book
  c)drop table book
  d)delete from book
  10)学生成绩表grade中有字段score(float),现在要把所有在55分至60之间的分数提高5分,以下sql语句正确的是()。(选择两项)
  a)Update grade set score=score+5
  b)Update grade set score=score+5 where score>=55 or score =55 and score 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)关于聚合函数,以下说法错误的是()。(选择一项)
  a)Sum返回表达式中所有数的总合,因此只能用于数字类型的列。
  b)Avg返回表达式中所有数的平均值,可以用于数字型和日期型的列。
  c)Max和Min可以用于字符型的列。
  d)Count可以用于字符型的列。
  17)使用以下()不可以进行模糊查询。(选择一项)
  a)OR
  b)Not between
  c)Not IN
  d)Like
  18)关于多表联接查询,以下()描述是错误的。(选择一项)
  a)外联接查询返回的结果集行数可能大于所有符合联接条件的结果集行数。
  b)多表联接查询必须使用到JOIN关键字
  c)内联接查询返回的结果是:所有符合联接条件的数据。
  d)在where子句中指定联接条件可以实现内联接查询。
  19)Sql语句:select * from students where SNO like ‘010[^0]%[A,B,C]%’,可能会查询出的SNO是()。(选择两项)
  a)01053090A #Hm3?
  b)01003090A01
  c)01053090D09
  d)0101A01
  20)关于Truncate table, 以下()描述是错误的。(选择两项)
  a)Truncate table 可跟Where从句,根据条件进行删除。
  b)Truncate table 用来删除表中所有数据。
  c)触发器对Truncate table无效。
  d)delete 比Truncate table速度快。
  21)创建一个名为‘Customers’的新表,同时要求新表中包含表‘clients’的所有记录,sql语句是()。(选择一项)
  a)Select into customers from clients  
  b)Select into customers from clients
  c)Insert into customers select  from clients
  d)Insert customers select * from clients
  22)关于主键,以下()说法是错误的。(选择两项)
  a)主键可以用来确保表中不存在重复的数据行。
  b)一个表必须有一个主键。
  c)一个表只能有一个主键。
  d)只能对整数型列设置主键。
  23)假设订单表orders用来存储订单信息,cid代表客户编号,money代表单次订购额,现要查询每个客户的订购次数和每个客户的订购总金额,下面()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。最多返回()条记录。(选择一项)
  a)10
  b)6
  c)4
  d)0
  25)以下描述不正确的是
  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-9999
  You have selected the phone number into a local variable as follows:
  DECLARE @PhoneNumber int Which statement will correctly format the number?
  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?
  a)Set the data type of the column to UniqueIdentifier.

  b)Set the data type of the column to int, and set the>  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>  “No Sales Found”
  How should you create the script?
  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 < 0
  PRINT ‘No sales found’
  ELSE
  PRINT ‘Year to date sales: ’ + STR (@ytd)
  GO
  29)You are a database developer for an insurance company. Information about the company's insurance policies is stored in a SQL Server 2000 database. You create a table named policy for this database by using the script shown below:
  CREATE TABLE Policy
  (
  PolicyNumber int NOT NULL DEFAULT (0),
  InsuredLastName CHAR (30) NOT NULL,
  InsuredFirstName CHAR (20) NOT NULL,
  InsuredBirthDate dattime NOT NULL,
  PolicyDate datetime NOT NULL,
  FaceAmount money NOT NULL,
  CONSTRAINT PK_Policy PRIMARY KEY (PolicyNumber)
  )
  Each time the company sells a new policy, the policy must be assigned a unique policy number. The database must assign a new policy number when a new policy is entered. What should you do?
  a)Create an INSTEAD OF INSERT trigger to generate a new policy number, and include the policy number in the data instead into the table.
  b)Create an INSTEAD OF UPDATE trigger to generate a new policy number, and include the policy number in the data inserted into the table.
  c)Create an AFTER UPDATE trigger to generate a new policy number, and include the policy number in the data inserted into the table.
  d)Replace the DEFAULT constraint with a AFTER INSERT trigger that generates a new policy number and includes the policy number in the data inserted into the table.
  30)You are a database developer for a marketing firm. You have designed a quarterly sales view. This view joins several tables and calculates aggregate information. You create a  view. You want to provide a parameterised query to access the data contained in your view. The output will be used in other SELECT lists. How should you accomplish this goal?

  a)Use an>  b)Create a stored procedure that accepts the parameter as input and returns a rowset with the result set.
  c)Create a scalar user-defined function that accepts the parameter as input.
  d)Create an inline user-defined function that accepts the parameter as input.
  二、填空题(每空一分共25分)
  1、关系R是1NF,当且仅当所有的基础域仅包含____
  2、主关键字应该具有____性,__性,__性。
  3、关系R是3NF,当且仅当R是2NF,并且所有非PK属性都是__于PK。
  4、Transact-SQL 语言包含语言,语言,语言。
  5、消除列重复的关键字是,使用_操作符从多个查询中创建单结果集,提交一个事务的语句为____
  6、SQLServer的两种授权模式分别为___和___
  7、有一个数据表其一行有5KB,有10000行数据,那么我们至少需要__M的数据库空间。
  8、数据完整性分为__,__,__.
  9、每个允许有_个簇索引,_索引是SQLServer默认选择。
  10、可以使用__关键字显示未加密存储过程信息,执行存储过程的关键字是_,统计列平均值的聚合函数为____,修改对象的关键字为_,删除对象的关键字为___
  11、____数据库保存所有的临时表和临时存储过程。
  三、简答题(15分)
  1、请简述一下第二范式(3分)
  2、请简述UPDATE 触发器工作原理(3分)
  3、强制引用完整性时,简述SQL Server 禁止用户进行的操作(3分)
  4、简述相关子查询的步骤(3分)
  5、简述使用索引和不使用索引的理由(3分)
  上机题(25分)
  一、(12分)问题描述:
  已知关系模式:
  S (SNO,SNAME)          学生关系。SNO 为学号,SNAME 为姓名
  C (CNO,CNAME,CTEACHER)  课程关系。CNO 为课程号,CNAME 为课程名,CTEACHER 为任课教师
  SC(SNO,CNO,SCGRADE)     选课关系。SCGRADE 为成绩

  •   找出没有选修过“李明”老师讲授课程的所有学生姓名(4分)
  •   列出有二门以上(含两门)不及格课程的学生姓名及其平均成绩(4分)
  • 列出既学过“1”号课程,又学过“2”号课程的所有学生姓名(4分)  二、定义一个十进制转换成2进制的标量函数。(4分)
      三、活期存款中,“储户”通过“存取款单”和“储蓄所”发生联系。假定储户包括:账号,姓名,电话,地址,存款额;“储蓄所”包括:储蓄所编号,名称,电话,地址(假定一个储户可以在不同得储蓄所存取款)
      1、写出设计以上表格的语句(4分)
      2、创建一个触发器TR1完成下面内容:
      当向“存取款单”表中插入数据时,如果存取标志=1则应该更改储户表让存款额加上存取金额,如果存取标志=0则应该更改储户表让存款额减去存取金额,如果余额不足显示余额不足错误。(5分)


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-620662-1-1.html 上篇帖子: SQL Server数据导入 下篇帖子: SQL Server 按照分类输出Excel
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表