copy does stop when breaking a unique index rule

From: Frederic OLIVIE <alf(at)grolier(dot)fr>
To: pgsql-general(at)postgresql(dot)org
Subject: copy does stop when breaking a unique index rule
Date: 1998-06-11 16:53:51
Message-ID: 35800B9F.5D9BE8FF@grolier.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have two questions about the copy (SQL or not) command.
If I understood it well, \copy is just an interface to the SQL copy
command.

First of all, it stops if a unique index rule is broken.
This means that one can not insert a set of datas using copy, and
relying on the database's core to drop off the non unique entries.

Am I wrong ? Is there any solution to force copy inserting all good
entries, and dropping the bad ones (e.g: in case of doubles) without
stopping it's execution ?

Second question is :

I have a very simple table with a sequence :

create sequence uidseq start 1;

CREATE TABLE users (
uid int4
default nextval('uidseq'), -- Primary Key
login varchar(15)
);

Can I use copy to fill in my users table, and relying on the system to
affect the right sequence numbers ?

e.g :

If I do :

INSERT INTO users (login) VALUES ('test') ;

Then, the right sequence number will be given.

But, if I import (copy) a file with the following format :

\t<login>

where \t stands for a tab sign, and using :

copy users from '/tmp/users';

Then, all my users get an uid of 0.

Thanks for any reply.

--
Frederic OLIVIE (Alf) - Information System Manager
GROLIER INTERACTIVE Europe / Online Groupe
11, rue de Cambrai, 75927, Paris Cedex 19, France
Voice : +33-(0)1-55-45-47-91, Fax : +33-(0)1-55-45-47-10
Mobile : +33-(0)6-03-03-33-50
MailTo:alf(at)grolier(dot)fr http://www.club-internet.fr

Very Funny Scotty, now beam down my clothes !!!
Captain James T. Kirk, Starship Enterprise.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message dave madden 1998-06-11 17:09:23 Re: [GENERAL] order by
Previous Message Jeffrey Lyon 1998-06-11 16:40:55 PostgreSQL/ODBC/WinNT?