Introduction
PostgreSQL’s ON CONFLICT clause is a useful construct that allows you to
handle cases where an insertion may violate a uniqueness constraint. It is
not standard SQL syntax, but an extension, like SQLite’s INSERT OR REPLACE.
Let’s say we have a table named tasks like this:
create table if not exists tasks
(
account_id integer not null,
task_name text not null,
task_desc text not null
);
-- Yes, I prefer lowercase SQL. Sue me
Say we want tasks to have unique names for each account. Let’s define a unique index for it:

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.