sql数据库基础面试题复习试题考试题 - 全

专业资料

A、 select trim(‘ hello ’) 返回值为: hello (前后都无空格) B、 select ltrim(rtrim(‘ hello ’)) 返回值为: hello (前后都无空格) C、 select replace(‘hello’,’e’,’o’) 返回值为: hollo D、 select right(‘hello’,3) 返回值为: llo

9、 在SQLServer 2005中,查询score表中stuName字段数据。( ) (选择一项)

A、 select * from score

B、 select * from score where stuName=”” C、 select stuName from score

D、 select stuName from score student=””

10、在SQL Server 2005中,假定有studentCourse(学生选修课)表,其结构为:sID(学

号),cID(课程.编号) ,score(成绩).那么列出所有选修课程超过5门的学生学号以及选修课数目的SQL 语句的是()。(选择一项)

a) select sID,count(cID) from studentcourse where count(cID)>5

b) select sID,count(cID) from studentcourse group by sID where count(cID)>5 c) select sID,count(cID) from studentcourse group by sID having count(cID)>5 d) select sID,count(cID) from studentcourse group by cID having count(cID)>5

11、在SQL Server 2005中,现有客户代表customer(主键:客户编号cid),包含10行数据。订单表orders(外键:客户编号cid),包含6行数据。执行sql语句:select * from customers inner join orders on customers.cid=orders.cid 返回5行记录,则执行sql语句:select * from customers inner join orders on customers.cid<>orders.cid将返回( )行记录。(选择一项)

A、 11 B、 55 C、 60 D、 5

12、在SQL Server2005中,有时候需要显示的列名为中文,下列哪项代码具有此功能( )。(选择一项)

A、 select stuName=’学员姓名’ from score B、 select * ‘学员姓名’ from score C、 select stuName ‘学员姓名’ from score D、 以上都不正确

13、取当前时间转换成10位字符串正确的是( )(选择一项)

A、 select convert(getdate())

word完美格式

专业资料

B、 select convert(char(10))

C、 select convert(char(10),getdate()) D、 以上都不正确

14、在SQL Server 2005中,查找student表中所有身份证号码CardNo的前三位为010或

020的记录,以下语句正确的是( )。(选择二项)

A、 select *from student where cardno like ‘010%’or ‘020%’

B、 select *from student where cardno like ‘010%’or cardno like ‘020%’ C、 select *from student where cardno like ‘0(1,2)0%’ D、 select *from student where cardno like ‘0[1,2]0%’

15、在SQL Server 2005中,学生表student中包含字段:学生编号sid (主键),学生姓名sName, 现在查询所有姓名重复的记录,以下语句正确的是( )。(选择一项)

A、 select * from student group by sName where count(sid)>1 B、 select * from student where count(sid)>1

C、 select a.* from student a,student b where a. sname=b.sname

D、 select a.* from student a,student b where a. sname=b.sname and a.sid!=b.sid

9、在SQL Server2005中,有一个product(产品)表,包含字段:pname(产品名称),要从此表中筛选出产品名称为“苹果”或者“香蕉”的纪录,下列语句正确的是( )(选择一项)

A、SELECT * FROM product ON pname=’苹果’ OR pname=’香蕉’ B、SELECT * FROM product ON pname=’苹果’ AND pname=’香蕉’ C、SELECT * FROM product WHERE pname=’苹果’ OR pname=’香蕉’ D、SELECT * FROM product WHERE pname=’苹果’ AND pname=’香蕉’

10、在SQL Server 2005中,要查找eatables 表中item_desc 字段的值以“CHOCO”开头(如CHOCOLATE、CHOCOPIE)的所有记录。下列SQL语句正确的是( )。(选择一项) A、select * from eatables where item_desc LIKE “CHOCO” B、select * from eatables where item_desc =“CHOCO_” C、select * from eatables where item_desc LIKE “CHOCO%” D、select * from eatables where item_desc LIKE “%CHOCO?”

11、在SQL Server2005数据库的聚合函数中,函数( )返回表达式中的平均值. (选择一项)

A、AVG B、SUM C、MIN D、COUNT

12、在SQL Server2005数据库中,有students(学生)表,包含字段:SID(学号),SName(姓名),Grade(成绩).现查找所有学员中成绩最高的前5名学员.下列SQL语句正确的是( ). (选择一项)

word完美格式

专业资料

A、SELECT TOP 5 FROM students ORDER BY Grade DESC B、SELECT TOP 5 FROM students ORDER BY Grade C、SELECT TOP 5 * FROM students ORDER BY Grade D、SELECT TOP 5 * FROM students ORDER BY Grade DESC 13、在SQL Server2005数据库中,客户表customers包含字段:客户编号cid和名称cname,订单表orders包含字段:客户编号cid,如果需要通过查询获得有订单的客户的名称,下面查询语句中( ) 可以实现该需求. (选择一项)

A、SELECT customers.cname from customers LEFT JOIN orders ON customers.cid = orders.cid

B、SELECT customers.cname from customers INNER JOIN orders ON customers.cid = orders.cid

C、SELECT customers.cname from customers RIGHT JOIN orders where customers.cid = orders.cid

D、SELECT customers.cname from customers JOIN orders WHERE customers.cid = orders.cid

14、以下运算符中( )不是SQL Server2005的T-SQL支持的逻辑运算符(选择一项) A、and B、no C、not D、or

15、在SQL Server2005数据库中,可以使用( )子句进行分组筛选(选择一项) A、where B、Order BY C、Having D、Group by

16、在SQLServer2005数据库系统中,使用T-SQL查询数据时,可以使用Order by子句对查询结果排序,如果不指定升序或者降序,将( )(选择一项)

A、不排序 B、按asc升序排序 C、按desc降序排序 D、出现语法错误

17、在SQL Server2005中,假设在Temp表中A列为商品名称,则查询以大写字母开头的所有商品名称的语句是( )(选择一项)

A、select A from Temp where A like '[A-Z]%' B、select A from Temp where A not like '[A-Z]%' C、select A from Temp where A like '%[A-Z]%' D、select A from Temp where A not like '%[A-Z]'

18、在SQL Server2005数据库中,有一个course(课程)表,包含字段;cName(课程名称),grade(学分)。要从此表中查询所有学分不在1-4之间的课程名称,以下语句正确的是( )(选择二项)

A、select cName from course where grade in(1,4)

B、select cName from course where grade not between 1 and 4 C、select cName from course where grade not between 4 and 1 D、select cName from course where not (grade>=1 and grade<=4)

19、在SQL Server2005数据库中有已经建立关系的学生表(子表,包含\班级编号\和\学号\字段)和班级表(主表,包含\班级编号\字段),要查询每个班级的学生人数,则以下查询语句

word完美格式

专业资料

中正确的是( ) (选择一项)

A、SELECT班级编号,COUNT(学号)FROM学生表达式GROUP BY 班级编号 B、SELECT班级编号,MAX(学号)FROM学生表达式GROUP BY 班级编号 C、SELECT班级编号,COUNT(学号)FROM学生表达式ORDER BY班级编号 D、SELECT班级编号,学号FROM学生表达式GROUP BY 班级编号

20、在SQL Server 2005中,假定一个学生选修课管理系统中有两个表,包括:student(学生)表,其结构为:sID(学号),sName(姓名);studentCourse(学生选课)表,其结构为:sID(学号),cID(课程编号),score(成绩)。那么列出所有已选课学生的学号、姓名、课程编号和成绩的SQL语句是( )(选择二项)

A、SELECT sID,sName,cID ,score FROM student,studentCourse B、SELECT sID,sName,cID ,score FROM student INNER JOIN studentCourse ON student.sID =studentCourse.sID C、SELECT sID,sName,cID ,score FROM student OUTER JOIN studentCourse ON student.sID =studentCourse.sID

D、SELECT sID,sName,cID ,score FROM student,studentCourse WHERE student.sID =studentCourse.sID

21、在SQL Server2005数据库中,系统提供聚合函数对列中的数据进行统计,以下聚合函数中,( )用于返回表示式中所有值中的最小值.(选择一项) A、sum B、min C、avg D、count

22、在SQL Server2005数据库中,现有student_info(学生)表,其中包括字段:stu_name(姓名,varchar型),stu_id(学号,int型),stu_grade(成绩,int型).现在需要查询成绩为80分的学员姓名,并且结果按照学号降序排列.下面查询语句正确的是( )(选择一项) A、select stu_name from student_info where stu_grade=80 order by stu_id

B、select stu_name from student_info where stu_grade=80 order by stu_id desc C、select stu_name from student_info where stu_grade like 80 group by stu_id D、select stu_name from student_info where stu_grade like 80 order by stu_id desc

23、在SQLServer 2005数据库中,如果一个T-SQL语句中包含多个逻辑运算符并且假设语句中没有括号时,其正确的运算顺序是( )(选择一项)

A、首先or ,然后NOT,最后计算AND B、首先NOT,然后OR,最后计算AND C、首先AND,然后OR,最后计算NOT D、首先NOT,然后AND,最后计算OR

24、在SQLServer2005数据库中,有学生信息表:Student(stuId,stuName,stu_Address),三个字段分别储存学生的学号,姓名以及家庭住址,如果要在表中找出家庭住址倒数第三个字符”沙”,并且至少包含4个字符的学生信息,则查询条件子句应写成( ). ( 选择一项) A、WHERE stu_Address LIKE '__沙_%' B、WHERE stu_Address LIKE '%沙__% C、WHERE stu_Address LIKE '%_沙__' D、WHERE stu_Address LIKE '__沙_%'

25、在SQL Server 2005中,学生表student中包含字段:学生编号sid (主键),学生姓名sName, 现在查询所有姓名重复的记录,一下语句正确的是( )(选择一项) A、select * from student where count(sid)>1

word完美格式

联系客服:779662525#qq.com(#替换为@)