1. 查看course表结构的SQL命令是什么?
A. SELECT * FROM exam.course;
B. \d exam.course;
C. \d+ exam.course;
D. DESCRIBE exam.course;
答案:C
2. 使用哪个SQL命令可以查看exam.course表中的所有数据?
A. SELECT * FROM exam.subject;
B. SELECT * FROM exam.course;
C. SHOW TABLES FROM exam.course;
D. DESCRIBE exam.course;
答案:B
3. 在SQL中,如何为字段别名添加双引号?
A. SELECT 1+1 AS '1+1=?' FROM dual;
B. SELECT 1+1 AS "1+1=?" FROM dual;
C. SELECT "1+1=?" FROM dual;
D. SELECT '1+1=?' FROM dual;
答案:B
4. SQL中,哪个命令用于选择所有列?
A. SELECT *
B. SELECT ALL
C. SELECT ALL COLUMNS
D. SELECT EVERY COLUMN
答案:A
5. SQL中字符串拼接运算符是什么?
A. +
B. ||
C. CONCAT()
D. JOIN()
答案:B
6. SQL中,哪个函数用于获取当前日期?
A. NOW()
B. CURRENT_DATE()
C. GETDATE()
D. DATE()
答案:B
7. SQL中,哪个关键字用于条件表达式?
A. IF
B. CASE
C. SWITCH
D. WHEN
答案:B
8. 在SQL中,哪个操作符用于数值型字段条件匹配?
A. =
B. >
C. <
D. LIKE
答案:ABC
9. SQL中,哪个关键字用于字符型字段条件匹配(等值匹配)?
A. IN
B. LIKE
C. =
D. MATCH
答案:C
10. SQL中,哪个关键字用于字符型字段条件匹配(列表匹配)?
A. IN
B. LIKE
C. =
D. MATCH
答案:A
11. SQL中,哪个关键字用于按注册日期升序排列?
A. ORDER BY reg_date DESC
B. ORDER BY reg_date ASC
C. SORT BY reg_date
D. RANK BY reg_date
答案:B
12. SQL中,哪个关键字用于多列组合排序?
A. ORDER BY city, reg_date DESC
B. SORT BY city, reg_date DESC
C. RANK BY city, reg_date DESC
D. GROUP BY city, reg_date DESC
答案:A
13. SQL中,哪个选项用于将NULL值始终放在排序的最前面?
A. NULLS LAST
B. NULLS FIRST
C. NULLS ASC
D. NULLS DESC
答案:B
14. SQL中,哪个子句用于限制查询结果的数量?
A. LIMIT
B. TOP
C. FETCH
D. SELECT
答案:A
15. SQL中,哪个函数用于计算去重后的城市数量?
A. COUNT(ALL city)
B. COUNT (DISTINCT city)
C. COUNT(city)
D. SUM(DISTINCT city)
答案:B
16. SQL中,如何表示字符串的拼接?
A. CONCAT('Hello', 'World')
B. 'Hello' + 'World'
C. 'Hello' || 'World'
D. 'Hello' & 'World'
答案:C
17. SQL中,如何表示选择当前日期加上7天的结果?
A. SELECT CURRENT_DATE + 7
B. SELECT GETDATE() + 7
C. SELECT CURRENT_DATE + INTERVAL '7 days'
D. SELECT current date()+7 As nextweek
答案:D
18. SQL中,如何使用CASE WHEN表达式来输出成绩等级?
A. CASE WHEN score >= 90 THEN 'High' END
B. CASE WHEN score >= 90 THEN 'High' WHEN score >= 70 THEN 'Medium' ELSE 'Low' END
C. IF score >= 90 THEN 'High' ELSE 'Low' END
D. SWITCH score >= 90 THEN 'High' END
答案:B
19. SQL中,如何查询分数大于80的学员信息?
A. SELECT * FROM exam.score WHERE score > 80
B. SELECT * FROM exam.score WHERE score >= 80
C. SELECT * FROM exam.score WHERE score = 80
D. SELECT * FROM exam.score WHERE score < 80
答案:A
20. SQL中,如何查询城市为Beijing的学员信息?
A. SELECT * FROM exam.student WHERE city = 'Beijing'
B. SELECT * FROM exam.student WHERE city LIKE 'Beijing'
C. SELECT * FROM exam.student WHERE city IN ('Beijing')
D. SELECT * FROM exam.student WHERE city != 'Beijing'
答案:A
21. SQL中,如何查询城市为Beijing或者Chongqing的学员信息?
A. SELECT * FROM exam.student WHERE city IN ('Beijing', 'Chongqing')
B. SELECT * FROM exam.student WHERE city = 'Beijing' OR city = 'Chongqing'
C. SELECT * FROM exam.student WHERE city LIKE 'Beijing' OR city LIKE 'Chongqing'
D. SELECT * FROM exam.student WHERE city = 'Beijing' AND city = 'Chongqing'
答案:A
22. SQL中,如何证明AND优先级高于OR?
A. SELECT 1 FROM dual WHERE 1=1 OR 1=0 AND 1=0
B. SELECT 1 FROM dual WHERE 1=1 AND 1=0 OR 1=1
C. SELECT 1 FROM dual WHERE 1=1 OR (1=0 AND 1=1)
答案:BC
23. SQL中,使用括号改变了AND的优先级?
A. SELECT 1 FROM dual WHERE 0=9 AND(0=1 OR 1=1)
B. SELECT 1 FROM dual WHERE 0=9 OR(0=1 AND 1=1)
C. SELECT 1 FROM dual WHERE 0=9 AND 0=1 OR 1=1
D. SELECT 1 FROM dual WHERE (0=9 AND 0=1) OR 1=1
答案:B
24. SQL中,如何查询姓名以'S'字符打头的学员信息?
A. SELECT * FROM exam.student WHERE sname LIKE 'S%'
B. SELECT * FROM exam.student WHERE sname LIKE '%S'
C. SELECT * FROM exam.student WHERE sname LIKE '_S'
D. SELECT * FROM exam.student WHERE sname LIKE 's%'
答案:A
25. SQL中,如何查询姓名以'g'字符结尾的学员信息?
A. SELECT * FROM exam.student WHERE sname LIKE '%g'
B. SELECT * FROM exam.student WHERE sname LIKE 'g%'
C. SELECT * FROM exam.student WHERE sname LIKE '_g'
D. SELECT * FROM exam.student WHERE sname LIKE 'G%'
答案:A