【2019年8月版】OCP 071認證考試原題-第42題

Choose two

Examine this SQL statement:

DELETE FROM employees e

WHERE EXISTS

(SELECT 'dummy'

FROM emp_history

WHERE employee_id = e.employee_id)

Which two are true?

A) The subquery is executed for every row in the EMPLOYEES table.

B) The subquery is not a correlated subquery.

C) The subquery is executed before the DELETE statement is executed.

D) All existing rows in the EMPLOYEEE table are deleted.

E) The DELETE statement executes successfully even if the subquery selects multiple rows.

Answer::AE

(解析:這又是一個關聯子查詢的考題,出現過多次,A 答案大家要注意。)

關聯子查詢:

1、 先執行主查詢,對於主查詢返回的每一行數據,都會造成子查詢執行一次

2、 然後子查詢返回的結果又傳給主查詢

3、 主查詢根據返回的記錄做出判斷

)

注意這道題答案 E 是對的,與前面第 14 題的答案 D 上有區別,要分別對待。

create table emp2 as select * from emp where deptno=20;

update emp2 set empno=7934 where ename=’SCOTT’;

DELETE FROM emp e

WHERE EXISTS

(SELECT 'empno'

FROM emp2

WHERE empno = e.empno);

UPDATE emp e

SET ename =

(SELECT ename

FROM emp2

WHERE empno = e.empno);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章