Migration Gotcha: Oracle MERGE INTO requires a source query (often FROM DUAL for single rows) and does not protect against race conditions unless paired with a UNIQUE constraint. PostgreSQL and SQLite require an explicit conflict target matching a unique index.

Oracle Database

MERGE INTO customers t
USING (SELECT :id AS id, :email AS email FROM dual) s
ON (t.id = s.id)
WHEN MATCHED THEN UPDATE SET t.email = s.email
WHEN NOT MATCHED THEN INSERT (id, email) VALUES (s.id, s.email);

PostgreSQL

INSERT INTO customers (id, email)
VALUES ($1, $2)
ON CONFLICT (id)
DO UPDATE SET email = EXCLUDED.email;

MySQL 8+

INSERT INTO customers (id, email)
VALUES (?, ?)
ON DUPLICATE KEY UPDATE email = VALUES(email);

SQLite 3

INSERT INTO customers (id, email)
VALUES (?1, ?2)
ON CONFLICT (id)
DO UPDATE SET email = excluded.email;