Upsert
An upsert inserts a row, or updates it if a row with the same key already exists — a single operation that means 'insert or update'.
Upserts avoid the race-prone pattern of checking for a row and then inserting or updating. The database does it atomically in one statement.
In PostgreSQL this is INSERT ... ON CONFLICT, where you specify the conflicting key and what to update. It's ideal for syncing data, counters, and idempotent writes.
Many client SDKs expose upsert directly, so you can write 'create or update this record' without custom transaction logic.
Related terms
See it in practice
Kolaybase gives you PostgreSQL, auth, storage, and a REST API in minutes.