读书人

[每天一题] OCP1z0-047 :2013-08-28

发布时间: 2013-10-08 16:32:36 作者: rapoo

[每日一题] OCP1z0-047 :2013-08-28 DELETE..........................................................160

转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/10475707

[每天一题]  OCP1z0-047 :2013-08-28   DELETE.160

[每天一题]  OCP1z0-047 :2013-08-28   DELETE.160

[每天一题]  OCP1z0-047 :2013-08-28   DELETE.160


正确答案:ACD


根据题库,操作如下:
 
A答案能删除:

oe@OCM> select count(*) from orders;    --主表  COUNT(*)----------       105oe@OCM> select count(*) from order_items;  --子表  COUNT(*)----------       665oe@OCM> delete from(select * from order_items i,orders o  2     WHERE i.order_id=o.order_id AND order_status in(0,1));110 rows deleted.oe@OCM> select count(*) from orders;   --记录没变  COUNT(*)----------       105oe@OCM> select count(*) from order_items;  --记录少了110条  COUNT(*)----------       555

有些人D答案百思不得期解,模拟这个操作时一直报错(ERROR at line 1:
ORA-01752: cannot delete from view without exactly one key-preserved table)原因就在于自己去建了两个表order和order_items时没有在这两个表上建约束主外键,并且加上主外键可以级联删除(CONSTRAINT "ORDER_ITEMS_ORDER_ID_FK" FOREIGN KEY ("ORDER_ID") REFERENCES "OE"."ORDERS" ("ORDER_ID") ON DELETE CASCADE ENABLE NOVALIDATE)。
这个我就不再测试了,太简单了。


QQ:252803295

学习交流QQ群:
DSI&Core Search Ⅰ 群:127149411(技术:已满)
DSI&Core Search Ⅱ 群:177089463(技术:未满)
DSI&Core Search Ⅲ 群:284596437(技术:未满)
DSI&Core Search Ⅳ 群:192136702(技术:未满)
DSI&Core Search Ⅴ 群:285030382(闲聊:未满)



MAIL:oracledba_cn@hotmail.com

BLOG: http://blog.csdn.net/guoyjoe

WEIBO:http://weibo.com/guoyJoe0218

ITPUB: http://www.itpub.net/space-uid-28460966.html

OCM: http://education.oracle.com/education/otn/YGuo.HTM


读书人网 >其他数据库

热点推荐