第5章 測驗
試卷總分:40 得分:100
一.單項選擇題(每小題3分,共10個題,30分)
1.當關系R和S進行連接操作時,如果R中的元組不滿足連接條件,在連接結果中也會將這些記錄保留下來的操作是( ?。?。
A.左外連接
B.右外連接
C.內(nèi)連接
D.自連接
2.聚合函數(shù)中,不忽略空值的是( ?。?。
A.SUM(列名)
B.MAX(列名)
C.AVG(列名)
D.COUNT(*)
3.查詢語句中,錯誤的是( ?。?/span>
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.現(xiàn)要利用Student表查詢年齡最小的學生姓名和年齡。下列實現(xiàn)此功能的查詢語句中,正確的是( )。
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。若在查詢成績時,希望將成績按‘優(yōu)’、‘良’、‘中’、‘及格’和‘不及格’形式顯示,正確的Case函數(shù)是( ?。?。
A.Case Grade
When 90~100 THEN ‘優(yōu)’
When 80~89 THEN ‘良’
When 70~79 THEN ‘中’
When 60~69 THEN ‘及格’
Else ‘不及格’
End
B.Case
When Grade between 90 and 100 THEN Grade = ‘優(yōu)’
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 ‘優(yōu)’
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 = ‘優(yōu)’
When 80~89 THEN Grade = ‘良’
When 70~79 THEN Grade = ‘中’
When 60~69 THEN Grade = ‘及格’
Else Grade = ‘不及格’
End
6.在SQL語句中,用于更新表數(shù)據(jù)的語句是( ?。?。
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) )
插入語句中,不能正確執(zhí)行的是( ?。?/span>
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.設數(shù)據(jù)庫中已有表5-1至5-3所示的Student、Course和SC表。現(xiàn)要查詢學生選的第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 ‘張_’ 語句中的’張_’ 用于查找姓張的學生。( ?。?/span>
12.SELECT * FROM Student WHERE Sname LIKE ‘[張李劉]%’ 語句可以查找姓張、李、劉的學生。( ?。?/span>
13.SELECT COUNT(DISTINCT Sno) FROM SC 語句用于統(tǒng)計學生的總人數(shù)。( ?。?/span>
14.HAVING子句用于對分組后的統(tǒng)計結果再進行過濾,它用于組而不是對單個記錄。( ?。?/span>
15.SELECT * FROM Student INNER JOIN SC
ON Student.Sno = SC.Sno 語句可將Student與 SC連接起來。( ?。?/span>
奧鵬,國開,廣開,電大在線,各省平臺,新疆一體化等平臺學習
詳情請咨詢QQ : 3230981406或微信:aopopenfd777