Search Postgresql Archives

Re: Problem with COPY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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    === 


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux