Top "Upsert" questions

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

SQLite "INSERT OR REPLACE INTO" vs. "UPDATE ... WHERE"

I've never seen the syntax INSERT OR REPLACE INTO names (id, name) VALUES (1, "John") used in SQL before, and I …

sqlite upsert
SQLite UPSERT / UPDATE OR INSERT

I need to perform UPSERT / INSERT OR UPDATE against a SQLite Database. There is the command INSERT OR REPLACE which …

database sqlite upsert
SQLite INSERT - ON DUPLICATE KEY UPDATE (UPSERT)

MySQL has something like this: INSERT INTO visits (ip, hits) VALUES ('127.0.0.1', 1) ON DUPLICATE KEY UPDATE hits = hits + 1; As …

sql mysql database sqlite upsert
How to Perform an UPSERT so that I can use both new and old values in update part

Stupid but simple example: Assume I have a table 'Item' where I keeps totals of the items that receive. Item_…

mysql performance upsert
Check if record exists, if yes "update" if not "insert"

I want to check table PREMIUM_SERVICE_USER if any records exists for strClientID update timeValid for +30 if no records …

sql-server stored-procedures merge sql-server-2000 upsert
How to use RETURNING with ON CONFLICT in PostgreSQL?

I have the following UPSERT in PostgreSQL 9.5: INSERT INTO chats ("user", "contact", "name") VALUES ($1, $2, $3), ($2, $1, NULL) ON CONFLICT("user", "contact") DO …

sql postgresql upsert sql-returning
Use multiple conflict_target in ON CONFLICT clause

I have two columns in table col1, col2, they both are unique indexed (col1 is unique and so is col2). …

postgresql upsert postgresql-9.5
How do I update if exists, insert if not (AKA "upsert" or "merge") in MySQL?

Is there an easy way to INSERT a row when it does not exist, or to UPDATE if it exists, …

sql mysql insert-update upsert
Does DB2 have an "insert or update" statement?

From my code (Java) I want to ensure that a row exists in the database (DB2) after my code is …

sql database db2 insert-update upsert
How to do an upsert with SqlAlchemy?

I have a record that I want to exist in the database if it is not there, and if it …

python sqlalchemy upsert