I want to add on conflict ignore to the Postgres copy
command.
I know I can copy the data to a table without unique index /primary key and then use insert with the on conflict
syntax.
But I wanted to know if this is possible directly from COPY
?
Postgresql – Postgres COPY with on conflict ignore – possible
copypostgresqlpostgresql-12
Related Question
- PostgreSQL – Export Data in Insert on Conflict Format
- PostgreSQL COPY – How to Use COPY FROM STDIN from Client App
- Postgresql – Is it possible to add a spatial index to a partition with Postgres 10
- PostgreSQL – How to Uniquely Append to Array on Conflict
- Postgresql – Stopping cascading logical replication
- PostgreSQL COPY Command – Usage and Examples
Best Answer
No. Maybe in some future version. Now about the best you can do is use file_fdw to map the file in as a foreign table, and then INSERT INTO...SELECT...ON CONFLICT DO NOTHING