SQL测试题目1.下列四项中,不属于数据库特点的是( D )。
A.数据共享B.数据完整性C.数据冗余很高D.数据独立性高2.SQL Server安装程序创建4个系统数据库,下列哪个不是( C )系统数据库。
A.masterB.modelC.pubD.msdb3.( A )是位于用户与操作系统之间的一层数据管理软件,它属于系统软件,它为用户或应用程序提供访问数据库的方法。
数据库在建立、使用和维护时由其统一管理、统一控制。
A.DBMS B.DB C.DBS D.DBA4. 下列哪个不是sql 数据库文件的后缀( C )。
A..mdf B..ldf C..tif D..ndf5.数据定义语言的缩写词为( A )。
A.DDLB.DCLC.DMLD.DBL6.数据库管理系统的英文缩写是( A )。
A.DBMS B.DBS C.DBA D.DB7.用于获取系统日期的函数是( B )。
A.YEAR()B.GETDATE()C.COUNT()D.SUM()8.SQL Server系统中的所有服务器级系统信息存储于哪个数据库( A )。
A. masterB. modelC. tempdbD. msdb9.以下关于外键和相应的主键之间的关系,正确的是( A )。
A.外键并不一定要与相应的主键同名B.外键一定要与相应的主键同名C.外键一定要与相应的主键同名而且唯一D.外键一定要与相应的主键同名,但并不一定唯一10. 模糊查找like '_a%',下面哪个结果是可能的( B )。
A.ailiB. baiC.bbaa11.使用( C )连接可以查询出表A和表B中符合连接条件的数据,不符合条件将不会出现在查询结果中。
A、左外联接B、右外联接C、内联接D、外联接12.下列聚合函数中正确的是( C )A、SUM (*)B、MAX (*)C、COUNT (*)D、A VG (*)13.每个数据库有且只有一个( A )A、主要数据文件B、次要数据文件C、日志文件D、索引文件14. 查询语句select stuff('he rld',3,l, 'llo wo')结果为( C )。
A.hello B.world hello C.hello world D.world15.限制输入到列的值的范围,应使用( A )约束。
A. CHECKB. PRIMARY KEYC. FOREIGN KEYD. UNIQUE16.执行select * from student where st_name like '%[^国]%',以下说法正确的是(C )。
(选择一项)A.查询出学生表中所有学生的记录B.查询出学生表中名字带有国字的学生记录C.查询出学生表中名字不带有国字的学生记录D.不能查询出学生表中有四个字名字的学生记录17.在student表中有name和age两个字段以下查询语句不能正确执行的是(C )。
(选择一项)A.Select name as 姓名,age as 年龄from studentB.Select name as '姓名',age as '年龄' from studentC.Select 姓名as name,年龄as age from studentD.Select 姓名=name,年龄=age from student18.下列语句能够正确执行的是( AD )。
(选择两项)A.Select st_id,st_name from student group by st_id,st_nameB.Select st_id,st_name from student group by st_idC.Select st_id ,avg(st_age) from student group by st_id,st_nameD.Select st_id,st_name,avg(st_age) from student group by st_id19. 在SELECT语句中正确的语法顺序如下(D)。
A.where ,having, group by,order byB.having,where , group by,order byC.where, order by ,group by,havingD.where , group by, having,order by20. 在student表中有11条记录,执行select top 10 precent * from student后返回的记录数是(B)。
A.1B.2C.10D.1121.在SQL server 2008 数据库中,有一个course (课程)表,包含字段:cName(课程名称),grade (学分) .要从此表中查询所有学分不在1~4之间的课程名称,以下语句正确的是(BD). (选两项)a) select cName From course where grade in (1,4)b) select cName From course where grade not between 1 and 4c) select cName From course where grade not between 4 and 1d) select cName From course where not (grade>=1 and grade<=4)22. 在SQL Server2008 数据库系统中,表Students 的主键Scode为表Score 的外键StudentID ,表Students含有5条数据,表Scode 含有10条数据,当对表Students 和表Score 进行如下查询时,将查询出(B)记录。
select s.scode from students as sfull join score as c on (s.scode = c.studentID)a) 5 b) 10 c) 15 d) 023. 在SQL Server 2008 数据库中,雇员信息表的结构如下所示,则选项中的语句能够正确查询出薪水低于2000元的性别为男性的雇员信息的是(AC)。
(选两项)a) select * from Employee where (NOT (Salary >= 2000 )) and (Sex = ‘男’)b) select * from Employee where(NOT(Salary >= 2000)) && (Sex = ‘男’)c) select * from Employee where (NOT (Salary >=2000) and (Sex = ‘男’))d) select * from Employee where (Salary <2000) &&(Sex =’男’)24. 在SQL Server2008 数据库中,有一个book(图书)表,包含字段:bookID(图书编号)、title(书名)、pDate(出版日期)、author(作者)等字段,其中(A)字段作为该表的主键是最恰当的。
a) bookID b) title c) pDate d) author25. 在SQL Server 2008 数据库的聚合函数中,函数(A)返回表达式中的平均值a) A VG b) SUM c) MIN d) COUNT26. 在SQL Server2008 数据库中,有students(学生)表,包含字段:SID(学号)、Sname(姓名)、Grade(成绩)。
现查找所有学员中成绩最高的前5名学员。
下列SQL语句正确的是(D)。
a) select top 5 from students order by Grade descb) select top 5 from student s order by Gradec) select top 5 * from students order by Graded) select top 5 * from students order by Grade desc27. 在SQL Server 2008数据库中,有学生信息表:Student(stuId, stuName,stu_Address)三个字段分别存储学生的学号、姓名、以及家庭住址,如果要在表中找出家庭住址倒数第三个字符为“沙”,并且至少包含4个字符的学生信息,则查询条件子名应写成(C)a) where stu_Address like' _ _ 沙_ %'b) where stu_Address like'%沙_ _'c) where stu_Address like '% _ 沙_ _'d) where stu_Address like ' _ 沙_ %'28. 在SQL Sever 2008 数据库中,客户表customers 包含字段:客户编号cid和名称cname,订单表orders 包含字段:客户编号cid如果需要通过查询获得有订单的客户名称,下面查询语句中(B)可以实现该需求。
a) select ame From customers Left join orderson customers.cid = orders.cidb) select ame From customers inner join orderson customers.cid = orders.cidc) select ame from customers right join orderswhere customers.cid = orders.cidd) select customers .cname from customers join orderswhere customers.cid = orders.cid29. 在SQL Server 2008数据库中,可以使用(C)关键字来判断表中是否存在包含空数据字段的记录行。
a) NONE b) NOT c) NULL d) NO30. 在SQL Server 2008 数据库中,字符串函数可以用于控制返回给用户的字符串,以下函数用于,将传递给它的字符串转变成大写(A)a) UPPER b) LOWER c) RTRIM d) STUFF31. 在使用SQL Server 2008 数据库时,有时需要将本机的数据库移动到其他机器上,恢复成对应的数据库使用移动数据库分两步进行,应包括(A)和附加数据库a) 分离数据库b) 删除数据库c) 新建数据库d) 合并数据库32. 在SQL Server 2008中,通配符通常与LIKE关键字一起配合使用,以下通配符中(C)表示在括号中指定范围内的一个字符。