Upsert a row in SQLite

Sql

Inserts, or updates the existing row when the unique column already holds that value.

INSERT INTO settings (key, value)
VALUES ('theme', 'dark')
ON CONFLICT(key) DO UPDATE SET
  value = excluded.value,
  updated_at = CURRENT_TIMESTAMP;

More in Databases

Random picks