国开《数据库应用技术》第5章 测验

此内容查看价格为3金币,请先
如有问题,请联系微信客服解决!

一.单项选择题(每小题3分,共10个题,30分)

1. 当关系R和S进行连接操作时,如果R中的元组不满足连接条件,在连接结果中也会将这些记录保留下来的操作是(  )。   

左外连接

右外连接

内连接

自连接

2. 聚合函数中,不忽略空值的是(  )。      

SUM(列名) 

MAX(列名)

AVG(列名)

COUNT(*)

3. 查询语句中,错误的是(  )。     

SELECT Sno, COUNT(*) FROM SC GROUP BY Sno

SELECT Sno FROM SC GROUP BY Sno WHERE COUNT(*) > 3

SELECT Sno FROM SC GROUP BY Sno HAVING COUNT(*) > 3

SELECT Sno FROM SC GROUP BY Sno

4. 现要利用Student表查询年龄最小的学生姓名和年龄。下列实现此功能的查询语句中,正确的是(  )。

SELECT Sname, MIN(Sage) FROM Student

SELECT Sname, Sage FROM Student WHERE Sage = MIN(Sage)

SELECT TOP 1 Sname, Sage FROM Student

SELECT TOP 1 Sname, Sage FROM Student ORDER BY Sage

5. 设SC表中记录成绩的列为:Grade,类型为int。若在查询成绩时,希望将成绩按‘优’、‘良’、‘中’、‘及格’和‘不及格’形式显示,正确的Case函数是(  )。     

Case Grade
 When 90~100  THEN  ‘优’
 When 80~89  THEN  ‘良’
 When 70~79  THEN  ‘中’
 When 60~69  THEN  ‘及格’
 Else  ‘不及格’
End

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

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

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语句中,用于更新表数据的语句是(  )。    

ALTER

SELECT

UPDATE  

INSERT

7. 设有Teachers表,该表的定义如下:

    CREATE TABLE Teachers(

      Tno CHAR(8) PRIMARY KEY,

      Tname VARCHAR(10) NOT NULL,

      Age TINYINT CHECK(Age BETWEEN 25 AND 65) )

插入语句中,不能正确执行的是(  )。   

INSERT INTO Teachers VALUES(‘T100′,’张宏’,NULL)

INSERT INTO Teachers(Tno,Tname,Age) VALUES(‘T100′,’张宏’,30)

INSERT INTO Teachers(Tno,Tname) VALUES(‘T100′,’张宏’)

INSERT INTO TeachersVALUES(‘T100′,’张宏’)

8. 设数据库中已有表5-1至5-3所示的Student、Course和SC表。现要查询学生选的第2学期开设课程的情况,只需列出学号、姓名、所在系和所选的课程号。该查询涉及到的表是(  )。     

仅Student表

仅Student和SC表

仅Student和Course表

Student、SC和Course表

9. 删除计算机系学生(在student表中)的修课记录(在SC表中)的语句,正确的是(  )。

DELETE  FROM SC JOIN Student b ON S.Sno = b.Sno
 WHERE Sdept = ‘计算机系’

DELETE FROM SC FROM SC JOIN Student b ON SC.Sno = b.Sno
 WHERE Sdept = ‘计算机系’

DELETE FROM Student  WHERE Sdept = ‘计算机系’

DELETE FROM SC WHERE Sdept = ‘计算机系’

10. 查询年龄最大的前5位学生的姓名和年龄的语句,正确的是(  )。

SELECT TOP 5 姓名, 年龄 FROM 学生表

SELECT TOP 5 姓名, 年龄 FROM 学生表 ORDER BY 年龄

SELECT TOP 5 姓名, 年龄 FROM 学生表 ORDER BY 年龄 DESC

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连接起来。(  )

社交账号快速登录

微信扫一扫关注
如已关注,请回复“登录”二字获取验证码