What is an upsert?
Model answer
Insert a row, or update it if it already exists. PostgreSQL and SQLite use INSERT ... ON CONFLICT (key) DO UPDATE, MySQL uses ON DUPLICATE KEY UPDATE, and standard SQL has MERGE. It needs a unique key and avoids race conditions of check-then-insert.
Learn this topic
INSERT, UPDATE and DELETE: Change Data Safely in the course SQL for Beginners: Learn Databases Step by Step.
Sign in to add your own answer.