A SQL statement typically used to `UPDATE` records when they exist and `INSERT` them when they do not.

Officially introduced in the SQL:2003 standard, and expanded in the SQL:2008 standard, MERGE does an INSERT for new records and an UPDATE of existing records depending on whether or not a condition matches.

Database management systems Oracle Database, DB2, Teradata and MS SQL support the standard syntax. Some also add non-standard SQL extensions that allow for things such as a DELETE action.

MERGE is similar to, but not synonymous with UPSERT.

history | excerpt history