DEV Community

Le Vuong
Le Vuong

Posted on

Using INSERT ON CONFLICT as an alternative to Upsert in Postgres

Wanna try another way to "Upsert" (update or insert) without using the upsert command? Modify your insert query to include the on conflict clause.

However, Postgres may spit out "No unique or exclusion constraint" if you don't define the unique constraint satisfying some of it conditions.

Please see detailed explanation on how to use the Insert with "on conflict" and how to avoid "No unique or exclusion constraint" error in this interesting post.

Top comments (0)