Merge Statement combines the sequence of the conditional INSERT and UPDATE Commands in a single atomic statement , Depending on the existence of a record. This operation is commonly known as Upsert Functionality.
Syntax:
MERGE INTO <RECEIVING_DATA_TABLE>
USING <BASE_DATA_TABLE>
WHEN MATCHED THEN
UPDATE SET <COL1>=<VALUE>,<COL2>=<VALUE>
WHEN NT MATCHED THEN
INSERT(COL1,COL2....)
VALUES(VAL1,VAL2....);
we can use merge command to perform insert , update in a single command.
No comments:
Post a Comment