merge into 相关操作

来源:互联网 发布:普通人如何利用大数据 编辑:程序博客网 时间:2024/05/23 01:19

今天看ocp题,有一个新的发现:


View the Exhibit and examine the data in ORDERS_MASTER and MONTHLY_ORDERS
tables. Evaluate the following MERGE statement:

MERGE INTO orders_master o
USING monthly_orders m
ON (o.order_id = m.order_id)
WHEN MATCHED THEN
UPDATE SET o.order_total = m.order_total
DELETE WHERE (m.order_total IS NULL)
WHEN NOT MATCHED THEN
INSERT VALUES (m.order_id, m.order_total);


What would be the outcome of the above statement?


A. The ORDERS_MASTER table would contain the ORDER_IDs 1 and 2.
B. The ORDERS_MASTER table would contain the ORDER_IDs 1, 2 and 3.
C. The ORDERS_MASTER table would contain the ORDER_IDs 1, 2 and 4.
D. The ORDERS_MASTER table would contain the ORDER_IDs 1, 2, 3 and 4.


Answer: C

当匹配上 的时候竟然可以执行两种操作;经过实验发现,这两种操作针对的是相同的行(两表匹配上的行),其余行不考虑;

原创粉丝点击