Re: mass import to table with unique index - Mailing list pgsql-general

From Manfred Koizar
Subject Re: mass import to table with unique index
Date
Msg-id j0vh3v8kmmf4n759qhb855bgijutojmk32@4ax.com
Whole thread Raw
In response to Re: mass import to table with unique index  (John Smith <john_smith_45678@yahoo.com>)
List pgsql-general
On Thu, 30 Jan 2003 01:41:51 -0800 (PST), John Smith
<john_smith_45678@yahoo.com> wrote:
>> I think that what the OP is looking for is the SQL*Server equivalent of
>> option IGNORE_DUP_KEY, where if you try to insert a record with that key
>> already included, it simply ignores that record.
>
>Exactly :)

John,  import into a temporary table and then

INSERT INTO original_table
SELECT DISTINCT ON (your, uniq, cols) *
  FROM temp_table t
 WHERE NOT EXISTS (
    SELECT * FROM original_table o
     WHERE o.your=t.your AND o.uniq=t.uniq AND o.cols=t.cols)
 ORDER BY your, uniq, cols, whatever;

HTH.
Servus
 Manfred

pgsql-general by date:

Previous
From: Justin Clift
Date:
Subject: Re: donations?
Next
From: "Peter Gibbs"
Date:
Subject: Re: 'GROUP BY' problem