Thread: copy does stop when breaking a unique index rule

copy does stop when breaking a unique index rule

From
Frederic OLIVIE
Date:
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@grolier.fr http://www.club-internet.fr

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

Problem creating a DB under 6.3.2 and Linux 2.00.33

From
Stefan Welzmiller
Date:
Hi

ive compiled and installed postgres, did the initdb under
user postgres and so on. i think, there is nothing i didn't
pay attention to.
but when "createdb test" under user postgres or any other
user i get the  following brainsmashing error:

----------------
Connection to database 'template1' failed.
connectDBU() failed: Is the postmaster running and accepting
connections at 'UNIX Socket' on port '5432'?
createdb: database creation failed on test.
----------------

btw, postmaster IS running and listening on port 5432,
because i didnt change the port before compiling. so the
default port (5432) must be used by the postmaster - isnt
it?.

thnx for your attention
regards
stefan