For the following question it is said that the answer should be C. But I think the correct answer is Answer D as NOT MATCHED block inserts all unmatching records to target table. Can anybody explain this? Thank you.
Q)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
                        
The correct answer is indeed C, this is because the source of the merge operation is the
monthly_orderstable, which only contains two records withorder_id2 and 3 respectively.Think about what will happen for each of these records:
order_id = 2, because this id exists in theorder_mastertable, we'll execute theMATCHEDpart of the merge statement, updating theorder_totalto 2500. Since the quantity for this record is notNULL, theDELETEwon't do anything.order_id = 3, again, the id exists in theorder_mastertable, so we execute theMATCHEDpart of the merge statement, updating theorder_totaltoNULLand then issuing a DELETE onorder_masterfor the row we just updated because the quantity onmonthly_orderisNULL.This leaves us with
order_id1, 2 and 4, which matches answer C.Code