Top "Upsert" questions

For issues relating to performing upsert (combination update/insert) operations.

Insert into a MySQL table or update if exists

I want to add a row to a database table, but if a row exists with the same unique key …

mysql sql insert-update upsert
Solutions for INSERT OR UPDATE on SQL Server

Assume a table structure of MyTable(KEY, datafield1, datafield2...). Often I want to either update an existing record, or insert …

sql sql-server database insert upsert
Insert, on duplicate update in PostgreSQL?

Several months ago I learned from an answer on Stack Overflow how to perform multiple updates at once in MySQL …

sql postgresql upsert sql-merge
INSERT IF NOT EXISTS ELSE UPDATE?

I've found a few "would be" solutions for the classic "How do I insert a new record or update one …

sqlite insert exists upsert merge-conflict-resolution
Oracle: how to UPSERT (update or insert into a table?)

The UPSERT operation either updates or inserts a row in a table, depending if the table already has a row …

sql oracle merge upsert
Postgres: INSERT if does not exist already

I'm using Python to write to a postgres database: sql_string = "INSERT INTO hundred (name,name_slug,status) VALUES (" sql_…

postgresql sql-insert upsert
SQLite - UPSERT *not* INSERT or REPLACE

http://en.wikipedia.org/wiki/Upsert Insert Update stored proc on SQL Server Is there some clever way to do …

sql sqlite upsert
How to UPSERT (MERGE, INSERT ... ON DUPLICATE UPDATE) in PostgreSQL?

A very frequently asked question here is how to do an upsert, which is what MySQL calls INSERT ... ON DUPLICATE …

postgresql insert-update upsert sql-merge
PostgreSQL INSERT ON CONFLICT UPDATE (upsert) use all excluded values

When you are upserting a row (PostgreSQL >= 9.5), and you want the possible INSERT to be exactly the same as …

postgresql upsert postgresql-9.5
How do I UPDATE a row in a table or INSERT it if it doesn't exist?

I have the following table of counters: CREATE TABLE cache ( key text PRIMARY KEY, generation int ); I would like to …

mysql sql sqlite postgresql upsert