SQLite has the ON CONFLICT
clause that allows you to specify how to handle constraint conflicts. It applies to UNIQUE
, NOT NULL
, CHECK
, and PRIMARY KEY
constraints (but not FOREIGN KEY
constraints).
There are five possible options you can use with this clause:
ABORT
FAIL
IGNORE
REPLACE
ROLLBACK
This article provides examples and an explanation of each of these options.
The ON CONFLICT
clause is used in CREATE TABLE
statements, but it can also be used when inserting or updating data by replacing ON CONFLICT
with OR
.