am  10.07.2006, um 10:21:59 +0200 mailte Christian Rengstl folgendes:
> Hi everyone,
> 
> I have a table with a surrogate key which is an integer sequence. Is
> there a way to load a file using COPY and tell postgresql not to
> insert into the primary key column?

Yes:

test=# create table foobar (id serial primary key, name text);
NOTICE:  CREATE TABLE will create implicit sequence "foobar_id_seq" for serial 
column "foobar.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "foobar_pkey" 
for table "foobar"
CREATE TABLE
test=*# copy foobar (name) from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> name1
>> name2
>> name3
>> \.
test=*# select * from foobar;
 id | name
----+-------
  1 | name1
  2 | name2
  3 | name3
(3 rows)


HTH, Andreas
-- 
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47215,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    === 

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to