- 在SQL中,如果需要删除表t01和t02并自动删除它们的依赖对象,应该使用哪个命令?
A. DROP TABLE t01, t02;
B. DROP TABLE IF EXISTS t01, t02;
C. DROP TABLE IF EXISTS t01 CASCADE; DROP TABLE IF EXISTS t02 CASCADE;
D. DROP TABLE t01 CASCADE; DROP TABLE t02 CASCADE;
答案:C
- 创建表t01和t02的正确SQL语句是什么?
A. CREATE TABLE t01(id1 int, id2 int, id3 int); CREATE TABLE t02(id1 int, id4 int, id5 int);
B. CREATE TABLE t01(id1 int,id2 int,id3 int): CREATE TABLE t02(id1 int,id4 int,id5 int);
C. CREATE TABLE t01(id1 int, id2 int, id3 int), t02(id1 int, id4 int, id5 int);
D. CREATE TABLE t01 {id1 int, id2 int, id3 int} CREATE TABLE t02 {id1 int, id4 int, id5 int}
答案:A
- 插入数据到t01和t02表的正确SQL命令是什么?
A. INSERT INTO t01 VALUES(1,1,1),(2,2,2),(3,3,3);
INSERT INTO t02 VALUES(1,4,4),(2,2,2),(4,6,6);
B. INSERT INTO t01 (1,1,1),(2,2,2),(3,3,3);
INSERT INTO t02 (1,4,4),(2,2,2),(4,6,6);
C. INSERT INTO t01 VALUES{1,1,1}, {2,2,2}, {3,3,3} ;
INSERT INTO t02 VALUES{1,4,4}, {2,2,2}, {4,6,6};
D. INSERT INTO t01 (VALUES(1,1,1),(2,2,2),(3,3,3)) ;
INSERT INTO t02 (VALUES(1,4,4),(2,2,2),(4,6,6));
答案:A
- 使用INNER JOIN子句查询t01和t02所有字段的正确SQL命令是什么?
A. SELECT * FROM t01 INNER JOIN t02 ON t01.id1=t02.id1
B. SELECT * FROM t01 JOIN t02 WHERE t01.id1=t02.id1
C. SELECT * FROM t01 INNER JOIN t02 WHERE t01.id1=t02.id1
D. SELECT * FROM t01, t02 WHERE t01.id1=t02.id1
答案:A
- 在SQL中,如何通过为表设置别名简化SQL语句?
A. SELECT * FROM t01 a INNER JOIN t02 b ON a.id1=b.id1
B. SELECT * FROM t01 AS a INNER JOIN t02 AS b ON a.id1=b.id1
C. SELECT * FROM t01 a JOIN t02 b WHERE a.id1=b.id1
D. SELECT * FROM t01 a, t02 b WHERE a.id1=b.id1
答案:A
- 以下哪个SQL命令表示等价于SELECT * FROM t01 a LEFT JOIN t02 b ON a.id1=b.id1;?
A. SELECT * FROM t01 a, t02 b WHERE a.id1=b.id1(+)
B. SELECT * FROM t01 a, t02 b WHERE a.id1=b.id1
C. SELECT * FROM t01 a RIGHT JOIN t02 b ON a.id1=b.id1
D. SELECT * FROM t01 a INNER JOIN t02 b ON a.id1=b.id1
答案:A
- 使用WHERE子句代替INNER JOIN ON关键字的正确SQL命令是什么?
A. SELECT * FROM t01 a, t02 b WHERE a.id1=b.id1
B. SELECT * FROM t01 a INNER JOIN t02 b WHERE a.id1=b.id1
C. SELECT * FROM t01 a JOIN t02 b ON a.id1=b.id1
D. SELECT * FROM t01 a, t02 b ON a.id1=b.id1
答案:A
- 左外连接(LEFT OUTER JOIN)的正确SQL命令是什么?
A. SELECT * FROM t01 a LEFT JOIN t02 b ON a.id1=b.id1
B. SELECT * FROM t01 a LEFT OUTER JOIN t02 b WHERE a.id1=b.id1
C. SELECT * FROM t01 a INNER JOIN t02 b ON a.id1=b.id1
D. SELECT * FROM t01 a, t02 b WHERE a.id1=b.id1
答案:A
- 全外连接(FULL OUTER JOIN)的正确SQL命令是什么?
A. SELECT * FROM t01 a FULL OUTER JOIN t02 b ON a.id1=b.id1
B. SELECT * FROM t01 a JOIN t02 b ON a.id1=b.id1
C. SELECT * FROM t01 a FULL JOIN t02 b ON a.id1=b.id1
D. SELECT * FROM t01 a, t02 b WHERE a.id1=b.id1
答案:A
- 交叉连接(CROSS JOIN)也称为什么?
A. 笛卡尔积
B. 内连接
C. 外连接
D. 自然连接
答案:A
- 在SQL中,非等值连接可以是哪种类型的连接?
A. 仅内连接
B. 仅外连接
C. 内连接或外连接
D. 自然连接
答案:C
- 以下哪个SQL命令表示全外连接?
A. SELECT * FROM t01 a LEFT JOIN t02 b ON a.id1=b.id1
B. SELECT * FROM t01 a RIGHT JOIN t02 b ON a.id1=b.id1
C. SELECT * FROM t01 a FULL OUTER JOIN t02 b ON a.id1=b.id1
D. SELECT * FROM t01 a INNER JOIN t02 b ON a.id1=b.id1
答案:C
- 自然连接可以是哪种类型的连接?
A. 仅内连接
B. 仅外连接
C. 内连接或外连接
D. 交叉连接
答案:C
- 使用USING关键字代替连接条件的SQL命令是什么?
A. SELECT * FROM t01 a INNER JOIN t02 b ON a.id1=b.id1
B. SELECT * FROM t01 a JOIN t02 b USING(id1)
C. SELECT * FROM t01 a, t02 b WHERE a.id1=b.id1
D. SELECT * FROM t01 a FULL OUTER JOIN t02 b ON a.id1=b.id1
答案:B
- 以下哪个SQL命令会生成笛卡尔积?
A. SELECT * FROM t01 a INNER JOIN t02 b ON a.id1=b.id1
B. SELECT * FROM t01 a CROSS JOIN t02 b
C. SELECT * FROM t01 a, t02 b WHERE a.id1=b.id1
D. SELECT * FROM t01 a INNER JOIN t02 b
答案:BD
- 当连接过程中提供了无效的连接条件,结果会变成什么?
A. 空集
B. 笛卡尔积
C. 内连接
D. 外连接
答案:B
- 以下哪个SQL命令表示左外连接?
A. SELECT * FROM t01 a LEFT JOIN t02 b ON a.id1=b.id1
B. SELECT * FROM t01 a RIGHT JOIN t02 b ON a.id1=b.id1
C. SELECT * FROM t01 a FULL OUTER JOIN t02 b ON a.id1=b.id1
D. SELECT * FROM t01 a INNER JOIN t02 b ON a.id1=b.id1
答案:A
- 以下哪个SQL命令表示右外连接?
A. SELECT * FROM t01 a RIGHT JOIN t02 b ON a.id1=b.id1
B. SELECT * FROM t01 a LEFT JOIN t02 b ON a.id1=b.id1
C. SELECT * FROM t01 a FULL OUTER JOIN t02 b ON a.id1=b.id1
D. SELECT * FROM t01 a INNER JOIN t02 b ON a.id1=b.id1
答案:A