【OCP最新題庫解析(052)–題44】USER1.EMP has a referential integrity

  • 2019 年 10 月 8 日
  • 筆記

該系列專題為2018年4月OCP-052考題變革後的最新題庫。題庫為小麥苗解答,若解答有不對之處,可留言,也可聯繫小麥苗進行修改。

註:OCP-052最新題庫完整詳細解答版請聯繫小麥苗私聊。解題不易,請大家尊重原創。

QQ:646634621

QQ群:547200174、618766405

微信號:lhrbestxh

Q

題目

USER1.EMP has a referential integrity constraint defined on EMP.DNO that references USER1.DEPT.DNO.

USER1 executes these commads:

SQL> UPDATE dept SET loc='UK' where dno=1;

1 row updated.

SQL>UPDATE emp SET sal=1000 where eno=100;

1 row updated.

SQL>ALTER TABLE dept DROP(dno);

What will be the outcome and why?

A. It will fail because a referential integrity constraint is defined on USER1.EMP

B. It will execute successfully and drop DEPNT.DNO.

C. It will fail because there is an uncommitted transaction on USER1.DEPT.

D. It will execute successfully and drop the DEPT.DNO and EMP.DNO columns.

E. It will fail because there is an uncommitted transaction on USER1.EMP

A

答案

Answer:A

外鍵(FOREIGN KEY),引用完整性約束(a referential integrity constraint),指明一個列或者列的組合作為一個外鍵,並且在相同表或者不同表的主鍵或者唯一鍵和外鍵之間建立一個關係。前提是被引用的外鍵必須是另外一個表的主鍵。

SCOTT@OCPLHR1> ALTER TABLE dept DROP(deptno);

ALTER TABLE dept DROP(deptno)

*

ERROR at line 1:

ORA-12992: cannot drop parent key column