A relational database management system uses SQL MERGE (aka. upsert) statements to INSERT new records or UPDATE existing records depending on whether or not a condition matches. It was officially introduced in the SQL:2003 standard.
- MERGE INTO table_name USING table_name ON (condition)
- WHEN MATCHED THEN UPDATE SET column1 = value1 [, column2 = value2 ...]
- WHEN NOT MATCHED THEN INSERT column1 [, column2 ...] VALUES (value1 [, value2 ...])
Some database management systems (like, e.g. MySQL) support SQL-command REPLACE, having the same effect.[1]
References
External links
| Database management systems | |
|---|---|
| Database
models · Database
normalization · Database
storage · Distributed
DBMS · Referential
integrity · Relational
algebra · Relational
calculus · Relational
database · Relational
DBMS · Relational model · |
|
| Concepts | Database · ACID · Null · Candidate key · Foreign key · Primary key · Superkey · Surrogate key |
| Objects | Trigger · View · Table · Cursor · Log · Transaction · Index · Stored procedure · Partition |
| SQL | Select · Insert · Update · Merge · Delete · Join · Union · Create · Drop · Begin work · Commit · Rollback · Truncate · Alter |
| Implementations | Relational · Flat file · Deductive · Dimensional · Hierarchical · Object-oriented · Object-relational · Temporal · XML data stores |
| Components | Concurrency control · Query language · Query optimizer · Query plan · ODBC · JDBC |
| Database products: Object-oriented (comparison) · Relational (comparison) | |
This entry is from Wikipedia, the leading user-contributed encyclopedia. It may not have been reviewed by professional editors (see full disclaimer)





