SQLite CRUD and SELECT Cheatsheet/Ignore duplicates on conflict

Keep the existing row when a unique key collides.

Section: Insert, update, delete, and upsert

Ignore duplicates on conflict

sql
sql
INSERT INTO tags (name) VALUES ('sqlite') ON CONFLICT(name) DO NOTHING;
Explanation

Useful for de-duplicated lookup tables and seeding scripts.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Insert, update, delete, and upsert
Insert one row
Add a new record.
OpenIn sheetsqlsame section
Insert multiple rows
Add several records in one statement.
OpenIn sheetsqlsame section
Update matching rows
Modify one or more records.
OpenIn sheetsqlsame section
Delete matching rows
Remove records by condition.
OpenIn sheetsqlsame section
Upsert with ON CONFLICT
Insert or update on a uniqueness collision.
OpenIn sheetsqlsame section
Select all columns
Read rows from a table.
OpenIn sheetsql1 tag match