1. 程式人生 > >【Oracle 12c】CUUG OCP認證071考試原題解析(30)

【Oracle 12c】CUUG OCP認證071考試原題解析(30)

tno eat ces 數據分析 nds table 不支持 commands 連接

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;

)

【Oracle 12c】CUUG OCP認證071考試原題解析(30)