20 March 2024

The "INSERT OR UPDATE" operation, often referred to as "UPSERT," is a database operation that either inserts a new row into a table if it doesn't already exist or updates an existing row if it does. In SQLite, there isn't a single SQL statement for UPSERT like in some other database systems. But there is "INSERT OR REPLACE", which is a SQL statement used to add a new row to a table. If a row with a matching key already exists, it updates that row with the new data. This method entirely replaces the existing row with the updated information.

Source code viewer
  1. INSERT OR REPLACE INTO TABLE_NAME (column1, column2, ...)
  2. VALUES (value1, value2, ...);
Programming Language: SQL