2018年oracle认证OCP考试052新题解析-192

 

192.

You execute this command.

SQL> DROP TABLE scott.item CASCADE CONSTRAINTS;

The ITEM table has a primary key that is referenced by a foreign key in the ORDERS table RECYCLEBIN IS enabled.

Which three statements are true ?

A) The ITEM table is moved to the RECYCLEBIN.

B) The ITEM table is dropped.

C) The foreign constraint on the ORDERS table is dropped.

D) The foreign constraint on the ORDERS table is disabled.

E) The ORDERS table is dropped.

F) The ORDERS table is moved to the RECYCLEBIN.

G) The foreign constraint on the ORDERS table is moved to the RECYCLEBIN.

解析:

--主表P,又称父表

create table p(pid number primary key,pname varchar2(10));

--从表C,又称子表,即引用主表主键作为其外键的表

create table c(

did number primary key,

pid number ,

cnt number,

constraint cpk FOREIGN KEY (pid) REFERENCES p(pid));

 

insert into p values (1,'a');

insert into p values (2,'b');

commit;

 

insert into c values (100,1,1);

insert into c values (200,2,1);

commit;

 

 

则当删除p表时,如不特殊说明,则 drop table p 系统会出现如下错误警告的信息而不会允许执行。

 

SQL> drop table p;

drop table p

           *

第 1 行出现错误:

ORA-02449: 表中的唯一/主键被外键引用

 

解决办法,使用语句可以刪除从表(或称子表)的constraint,从而可实现主表(或称父表)的drop;

 

SQL> Drop table p cascade constraints;

 

表已删除。

 

 

SQL> Flashback table p to before drop;

闪回完成

 

insert into c values (300,3,1);

SQL> commit;

 

SQL> select * from p;

 

       PID PNAME

---------- ----------

         1 a

         2 b

 

SQL> select * from c;

 

       DID        PID        CNT

---------- ---------- ----------

       100          1          1

       200          2          1

       300          3          1

 

SQL> insert into p values (1,'c');

第 1 行出现错误:

ORA-00001: 违反唯一约束条件 (TEST.BIN$YFRv1nd6QU+BOVRlpS8pKw==$0)

SQL> insert into c values (200,2,1);

第 1 行出现错误:

ORA-00001: 违反唯一约束条件 (TEST.SYS_C0011128)

 

更多2018年oracle认证OCP考试071新题解析讨论请加入QQ群:479384490

更多2018年oracle认证OCP考试052新题解析讨论请加入QQ群:479384490

更多2018年oracle认证OCP考试053新题解析讨论请加入QQ群:479384490

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值