liveBook · Manning

Do nothing clause

As explained in DuckDB in Action

DO NOTHING is SQL conflict-handling syntax that skips an insert when it violates a uniqueness constraint.

DO NOTHING is SQL conflict-handling syntax that skips an INSERT when a uniqueness constraint is violated. In an INSERT ... ON CONFLICT statement, it targets the primary index by default, making a repeated insert idempotent instead of raising an error. section 3.4.1

Ignore a duplicate primary key

INSERT INTO prices VALUES (1, 11.59, '2018-12-01', '2019-01-01') ON CONFLICT DO NOTHING; A second execution skips the conflicting row. This avoids an error, but it may also leave an existing row unchanged when a replacement or corrected insert was intended. section 3.4.1

INSERT INTO prices
VALUES (1, 11.59, '2018-12-01', '2019-01-01')
ON CONFLICT DO NOTHING;

Inspect the compact INSERT form that suppresses a uniqueness conflict. section 3.4.1

How DuckDB in Action covers it

How deep it goes
Explains default primary-index targeting and idempotency, but defers replacement behavior to DO UPDATE.
Examples
Demonstrates a repeated prices insert with an explicit primary-key value.
What it assumes
Assumes familiarity with INSERT statements, primary keys, and uniqueness constraints.
What you can do after
Apply it via SQL to make duplicate inserts complete without errors.
How it connects
Ties INSERT statements to primary keys, unique constraints, idempotency, and DO UPDATE.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of DuckDB in Action. The section links point to the parts of the book it draws on.