What is an upsert, and which SQL dialects have a native way to express it?
An upsert is a single statement that inserts a row, or updates it if a row with the same key already exists. It exists because the alternative is a read-then-write in application code, which is a race: two concurrent requests can both see that no row exists and both insert, and one of them violates a unique constraint.
There are three native spellings. The standard SQL:2003 form is INSERT ... ON CONFLICT (key) DO UPDATE SET ..., supported by PostgreSQL and SQLite. MySQL and MariaDB use INSERT ... ON DUPLICATE KEY UPDATE ..., where the conflicting column is not named — the engine works out which unique index was violated. SQL Server and Oracle have the full MERGE statement, which can insert, update, delete and do it all in one pass with a source table.
The difference in the spellings is more than cosmetic. ON CONFLICT requires you to name the conflict target, so you must know which unique constraint you are resolving. MySQL's version infers it, which is convenient but means the statement's behaviour depends on the schema's indexes. MERGE is the most powerful and the most verbose, and it is the only one that can handle a source with several rows per target key.
Two behaviours to know about. The update branch sees the existing row through the table's own name and the proposed row through the special excluded alias, so SET qty = inventory.qty + excluded.qty accumulates rather than replaces. And an ON CONFLICT DO NOTHING silently skips the conflicting row, which is exactly right for idempotent ingestion and exactly wrong if you expected to be told that something was skipped — so count the skips if they matter.