Replace (Update/Insert) a row into Oracle table – Merge into


In Mysql,  if you want to either updates or inserts a row in a table, depending if the table already has a row that matches the data, you can use “ON DUPLICATE KEY UPDATE”.

How to do it in Oracle?

Use “merge into” .

MERGE INTO employees USING dual ON ( "id"=123456 )
WHEN MATCHED THEN UPDATE SET "last_name"="smith" , "first_name"="bob"
WHEN NOT MATCHED THEN INSERT ("id","last_name","first_name")
    VALUES ( 123456,"smith", "bob" )


In SQL Server, .

In DB2, .

In PostgreSQL,

In Sqlite,

Some Oracle tools you can try: