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

From John Smith
Subject Re: mass import to table with unique index
Date
Msg-id 20030130094151.63302.qmail@web40701.mail.yahoo.com
Whole thread Raw
In response to mass import to table with unique index  (John Smith <john_smith_45678@yahoo.com>)
Responses Re: mass import to table with unique index
List pgsql-general

>>
>> Is there a way to mass import (like COPY, INSERT INTO ... SELECT ...) data into
>> an existing table with existing data that has a unique index?
>> Such as importing data with SSNs, and there's a unique index on the SSN column.
>> MySQL has an 'IGNORE' option for mass imports. Any way with PostgreSQL? Or only
>> with an INSERT command for each record?

>I don't understand. Why wouldn't copy work in this case? It does insert only
>and it does check index, if I am not making a mistake.

>I am not sure you want the contraint in place while it is mass importing. You
>can always drop the index, mass import data and recreate index if you are sure
>what you are doing..

COPY aborts after any encountered errors (like the first duplicate record). Creating a unique index (after dropping it) doesn't work either - it bails with a 'column data isn't unique' error.

> 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

 



Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now

pgsql-general by date:

Previous
From: Holger Klawitter
Date:
Subject: Re: Firewalls and Postgres
Next
From: "Mark Cave-Ayland"
Date:
Subject: Re: Ref to last INSERT on a table without OIDs?