From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | Ryan Mahoney <ryan(at)paymentalliance(dot)net>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: COPY and duplicates |
Date: | 2001-07-13 18:10:43 |
Message-ID: | 20010713131043.A14421@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Jul 13, 2001 at 11:01:28AM -0500,
Bruno Wolff III <bruno(at)wolff(dot)to> wrote:
> On Fri, Jul 13, 2001 at 09:40:24AM -0400,
> Ryan Mahoney <ryan(at)paymentalliance(dot)net> wrote:
> > Is it possible for the COPY command to warn about duplicate key violations
> > (and not insert them...) but still proceed inserting the rows that do not
> > cause a violation? If not, what is the quickest way to deal with this problem?
>
> You could copy the data into a temporary table and then insert just
> run record from a set with the same key into the real table.
As Ryan pointed out to me, I bolixed up the grammer in my response.
You can do want you want using copy to load a temporary table that
doesn't have a unique key constraint and then use insert to insert
data from a select on the temporary table using the distinct on clause
to pick one record from a set of records with the same key.
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2001-07-13 18:18:44 | Nusphere/MySQL-AB arguing |
Previous Message | eddie iannuccelli | 2001-07-13 17:51:13 | Outer joins |