Wednesday, March 14, 2012

merge statement in oracle

merge statement is especially useful for copy data of reference tables. since truncate and insert would work for refernece table with data in child table.

merge statement provide the best way to manipulate data in a parent reference table.

MERGE INTO test1 a
USING all_objects b
ON (a.object_id = b.object_id)
WHEN MATCHED THEN
UPDATE SET a.status = b.status
WHEN NOT MATCHED THEN
INSERT (object_id, status)
VALUES (b.object_id, b.status);


reference:
http://www.oracle-base.com/articles/10g/MergeEnhancements10g.php

No comments:

Post a Comment