30.choose the best answer
Examine the commands used to create DEPARTMENT_DETAILS and COURSE_DETAILS:
SQL> CREATE TABLE DEPARTMENT_DETAILS
(DEPARTMENT_ID NUMBER PRIMARY KEY,
DEPARTMENT_NAME VARCHAR2(50) ,
HOD VARCHAR2(50));
SQL> CREATE TABLE COURSE_DETAILS
(COURSE_ID NUMBER PRIMARY KEY,
COURSE_NAME VARCHAR2 (50) ,
DEPARTMENT_ID NUMBER REFERENCES DEPARTMENT_DETAILS(DEPARTMENT_ID));
You want to generate a list of all department IDs that do not exist in the
COURSE_DETAILS table.
You execute the SQL statement:
SQL> SELECT d.department_id FROM course_details c INNER JOIN department_details d
ON c.department_id<>d.department_id;
What is the outcome?
A) It fails because the ON clause condition is not valid.
B) It executes successfully and displays the required list.
C) It executes successfully but displays an incorrect list.
D) It fails because the join type used is incorrect.
Answer:C
(如果条件中用<>,得从来的结果就是笛卡尔积,inner join 并不以谁为基础,它只显示符
合条件的记录
联合连接(UNION JOIN):这是一种很少见的连接方式。Oracle、MySQL 均不支持,其作用
是:找出全外连接和内连接之间差异的所有行。这在数据分析中排错中比较常用。也可以利
用数据库的集合操作来实现此功能。
ORACLE 中可以用 minus 等同联合连接的功能。
select deptno from dept
minus
select deptno from emp;
)
阅读(857) | 评论(0) | 转发(0) |