From: Craig Ringer <ringerc@ringerc.id.au>
To: Saravanan Nagarajan <n.saravanan86@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: duplicate key value violates unique constraint "tableName_pk"
Date: Thu, 08 Nov 2012 10:19:56 +0800
Message-ID: <509B16CC.5050905@ringerc.id.au> (raw)
In-Reply-To: <CANYLzthssbdi4LSYmL9NJ6XsHJcm=Ni8qBMEJtzuij4jCO7Gtw@mail.gmail.com>
References: <CANYLzthssbdi4LSYmL9NJ6XsHJcm=Ni8qBMEJtzuij4jCO7Gtw@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: ringerc@ringerc.id.au, n.saravanan86@gmail.com
Subject: Re: duplicate key value violates unique constraint "tableName_pk"
In-Reply-To: <509B16CC.5050905@ringerc.id.au>
References: <CANYLzthssbdi4LSYmL9NJ6XsHJcm=Ni8qBMEJtzuij4jCO7Gtw@mail.gmail.com> <509B16CC.5050905@ringerc.id.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox