Re: duplicate key value violates unique constraint "tableName_pk" - Mailing list pgsql-bugs

From Craig Ringer
Subject Re: duplicate key value violates unique constraint "tableName_pk"
Date
Msg-id 509B16CC.5050905@ringerc.id.au
Whole thread Raw
In response to duplicate key value violates unique constraint "tableName_pk"  (Saravanan Nagarajan <n.saravanan86@gmail.com>)
List pgsql-bugs
On 11/07/2012 07:21 PM, Saravanan Nagarajan wrote:
> Hi ,
>
> I am using "Copy From" while dumping bulk data into PGSQL DB from
> file. While I am trying to insert the rows, if the primary key already
> exists, the complete transaction terminated.
>
> Postgres cannot handle the constraint violations , i found it
> into http://wiki.postgresql.org/wiki/COPY#Caveats_with_implementation .
>
> Is there any possible way to insert bulk data using "Copy From" with
> REPLACE/IGNORE duplicates.
Typically you COPY into a temporary or UNLOGGED table, then merge the
data into the target table using appropriate `UPDATE ... FROM ... WHERE`
and `INSERT ... SELECT ... WHERE` statements.

--
Craig Ringer

pgsql-bugs by date:

Previous
From: Tianyin Xu
Date:
Subject: Re: [BUGS] BUG #7642: Unchecked “stats_temp_directory” causes server hang to requests
Next
From: Denis Feklushkin
Date:
Subject: Re: PQsendQueryParams() causes prepared statement error