第5章 测验
试卷总分:40 得分:100
一.单项选择题(每小题3分,共10个题,30分)
1.当关系R和S进行连接操作时,如果R中的元组不满足连接条件,在连接结果中也会将这些记录保留下来的操作是( )。
A.左外连接
B.右外连接
C.内连接
D.自连接
2.聚合函数中,不忽略空值的是( )。
A.SUM(列名)
B.MAX(列名)
C.AVG(列名)
D.COUNT(*)
3.查询语句中,错误的是( )。
A.SELECT Sno, COUNT(*) FROM SC GROUP BY Sno
B.SELECT Sno FROM SC GROUP BY Sno WHERE COUNT(*) > 3
C.SELECT Sno FROM SC GROUP BY Sno HAVING COUNT(*) > 3
D.SELECT Sno FROM SC GROUP BY Sno
4.现要利用Student表查询年龄最小的学生姓名和年龄。下列实现此功能的查询语句中,正确的是( )。
A.SELECT Sname, MIN(Sage) FROM Student
B.SELECT Sname, Sage FROM Student WHERE Sage = MIN(Sage)
C.SELECT TOP 1 Sname, Sage FROM Student
D.SELECT TOP 1 Sname, Sage FROM Student ORDER BY Sage
5.设SC表中记录成绩的列为:Grade,类型为int。若在查询成绩时,希望将成绩按‘优’、‘良’、‘中’、‘及格’和‘不及格’形式显示,正确的Case函数是( )。
A.Case Grade
When 90~100 THEN ‘优’
When 80~89 THEN ‘良’
When 70~79 THEN ‘中’
When 60~69 THEN ‘及格’
Else ‘不及格’
End
B.Case
When Grade between 90 and 100 THEN Grade = ‘优’
When Grade between 80 and 89 THEN Grade = ‘良’
When Grade between 70 and 79 THEN Grade = ‘中
When Grade between 60 and 69 THEN Grade = ‘及格’
Else Grade = ‘不及格’
End
C.Case
When Grade between 90 and 100 THEN ‘优’
When Grade between 80 and 89 THEN ‘良’
When Grade between 70 and 79 THEN ‘中’
When Grade between 60 and 69 THEN ‘及格’
Else ‘不及格’
End
D.Case Grade
When 90~100 THEN Grade = ‘优’
When 80~89 THEN Grade = ‘良’
When 70~79 THEN Grade = ‘中’
When 60~69 THEN Grade = ‘及格’
Else Grade = ‘不及格’
End
6.在SQL语句中,用于更新表数据的语句是( )。
A.ALTER
B.SELECT
C.UPDATE
D.INSERT
7.设有Teachers表,该表的定义如下:
CREATE TABLE Teachers(
Tno CHAR(8) PRIMARY KEY,
Tname VARCHAR(10) NOT NULL,
Age TINYINT CHECK(Age BETWEEN 25 AND 65) )
插入语句中,不能正确执行的是( )。
A.INSERT INTO Teachers VALUES(‘T100′,’张宏’,NULL)
B.INSERT INTO Teachers(Tno,Tname,Age) VALUES(‘T100′,’张宏’,30)
C.INSERT INTO Teachers(Tno,Tname) VALUES(‘T100′,’张宏’)
D.INSERT INTO TeachersVALUES(‘T100′,’张宏’)
8.设数据库中已有表5-1至5-3所示的Student、Course和SC表。现要查询学生选的第2学期开设课程的情况,只需列出学号、姓名、所在系和所选的课程号。该查询涉及到的表是( )。
A.仅Student表
B.仅Student和SC表
C.仅Student和Course表
D.Student、SC和Course表
9.删除计算机系学生(在student表中)的修课记录(在SC表中)的语句,正确的是( )。
A.DELETE FROM SC JOIN Student b ON S.Sno = b.Sno
WHERE Sdept = ‘计算机系’
B.DELETE FROM SC FROM SC JOIN Student b ON SC.Sno = b.Sno
WHERE Sdept = ‘计算机系’
C.DELETE FROM Student WHERE Sdept = ‘计算机系’
D.DELETE FROM SC WHERE Sdept = ‘计算机系’
10.查询年龄最大的前5位学生的姓名和年龄的语句,正确的是( )。
A.SELECT TOP 5 姓名, 年龄 FROM 学生表
B.SELECT TOP 5 姓名, 年龄 FROM 学生表 ORDER BY 年龄
C.SELECT TOP 5 姓名, 年龄 FROM 学生表 ORDER BY 年龄 DESC
D.SELECT TOP 5 WITH TIES姓名, 年龄 FROM 学生表
二.判断题(每小题2分,共5个题,10分)
11.SELECT * FROM Student WHERE Sname LIKE ‘张_’ 语句中的’张_’ 用于查找姓张的学生。( )
12.SELECT * FROM Student WHERE Sname LIKE ‘[张李刘]%’ 语句可以查找姓张、李、刘的学生。( )
13.SELECT COUNT(DISTINCT Sno) FROM SC 语句用于统计学生的总人数。( )
14.HAVING子句用于对分组后的统计结果再进行过滤,它用于组而不是对单个记录。( )
15.SELECT * FROM Student INNER JOIN SC
ON Student.Sno = SC.Sno 语句可将Student与 SC连接起来。( )
奥鹏,国开,广开,电大在线,各省平台,新疆一体化等平台学习
详情请咨询QQ : 3230981406或微信:aopopenfd777