OCP-047insert into subquery with check option values()

24. View the Exhibit and examine the structure of the ORDERS table:
The ORDER_ID column has the PRIMARY KEY constraint and CUSTOMER_ID has the
NOT NULL constraint.
Evaluate the following statement:
INSERT INTO (SELECT order_id,order_date,customer_id
FROM ORDERS
WHERE order_total = 1000 WITH CHECK OPTION)
VALUES (13, SYSDATE, 101).
What would be the outcome of the above INSERT statement?
A. It would execute successfully and the new row would be inserted into a
new temporary table created by the subquery.
B. It would execute successfully and the ORDER_TOTAL column would have the
value 1000 inserted automatically in the new row.
C. It would not execute successfully because the ORDER_TOTAL column is not
specified in the SELECT list and no value is provided for it.
D. It would not execute successfully because all the columns from the ORDERS
table should have been included in the SELECT list and values should have
been provided for all the columns.
Answer: C


insert into (<subquery > WITH CHECK OPTION) values (...)
1: insert into subquery 里的这张表,如果插入的对应列值不满足subquery 里的where 条件的话,就不允许插入。
2: 如果插入的列有不在子查询里作为检查的where 条件的话,不允许插入
3:如果不加WITH CHECK OPTION 则在插入时不会检查。


官方文档中给出的例子:

Using the WITH CHECK OPTION Clause: Example The following statement is legal even though the third value inserted violates the condition of the subquery where_clause:

INSERT INTO (SELECT department_id, department_name, location_id
   FROM departments WHERE location_id < 2000)
   VALUES (9999, 'Entertainment', 2500);

However, the following statement is illegal because it contains the WITH CHECK OPTION clause:

INSERT INTO (SELECT department_id, department_name, location_id
   FROM departments WHERE location_id < 2000 WITH CHECK OPTION)
   VALUES (9999, 'Entertainment', 2500);
     *
ERROR at line 2:
ORA-01402: view WITH CHECK OPTION where-clause violation
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值