In MySQL we use
REPLACE INTO
to insert if a row doesn't exist and to update if it exists.
Is there a corresponding command in Oracle?
In MySQL we use
REPLACE INTO
to insert if a row doesn't exist and to update if it exists.
Is there a corresponding command in Oracle?
MERGE
INTO destTable d
USING (
SELECT *
FROM sourceTable
) s
ON (s.id = d.id)
WHEN NOT MATCHED THEN
INSERT (id, destCol1, destCol2)
VALUES (id, sourceCol1, sourceCol2)
WHEN MATCHED THEN
UPDATE
SET destCol1 = sourceCol1,
destCol2 = sourceCol2
You are looking for something like Merge
in Oracle
Use
Merge Into myTable s
USING Select x from y;