第4章 数据操作语句
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
第 4 章数据操作语句
一.选择题
1.当关系R和S进行连接操作时,如果R中的元组不满足连接条件,在连接结果中也会将这些记录保留下来的操作是A
A.左外连接B.右外连接
C.内连接D.自连接
2.设在某SELECT语句的WHERE子句中,需要对Grade列的空值进行处理。下列关于空值的操作,错误的是C
A.Grade IS NOT NULL B.Grade IS NULL
C.Grade = NULL D.NOT (Grade IS NULL)
3.下列聚合函数中,不忽略空值的是D
A.SUM(列名) B.MAX(列名)
C.A VG(列名) D.COUNT(*)
4.SELECT … INTO …FROM语句的功能是A
A.将查询结果插入到一个新表中
B.将查询结果插入到一个已建好的表中
C.合并查询的结果
D.向已存在的表中添加数据
5.下列利用SC表的查询语句中,错误的是B
A.SELECT Sno, COUNT(*) FROM SC GROUP BY Sno
B.S ELECT 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
6.现要利用Student表查询年龄最小的学生姓名和年龄。下列实现此功能的查询语句中,正确的是D
A.SELECT Sname, MIN(Sage) FROM Student
B.S ELECT 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
7.设SC表中记录成绩的列为:Grade,类型为int。若在查询成绩时,希望将成绩按‘优’、‘良’、‘中’、‘及格’和‘不及格’形式显示,正确的Case函数是C
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
8.下述语句的功能是将两个查询结果合并为一个结果。其中正确的是B A.select sno,sname,sage from student where sdept = 'cs' Order by sage
Union
select sno,sname,sage from student where sdept = 'is' Order by sage
B.s elect sno,sname,sage from student where sdept = 'cs' Union
select sno,sname,sage from student where sdept = 'is' Order by sage
C.select sno,sname,sage from student where sdept = 'cs' Union
select sno,sname from student where sdept = 'is'
Order by sage
D.select sno,sname,sage from student where sdept = 'cs' Order by sage
Union
select sno,sname,sage from student where sdept = 'is'
9.下列SQL语句中,用于修改表数据的语句是C
A.ALTER B.SELECT
C.UPDATE D.INSERT
10.设有Teachers表,该表的定义如下:
CREATE TABLE Teachers(
Tno CHAR(8) PRIMARY KEY,