From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Problem with COPY |
Date: | 2006-07-10 09:28:37 |
Message-ID: | 20060710092837.GC29774@webserv.wug-glas.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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 ===
From | Date | Subject | |
---|---|---|---|
Next Message | DANTE Alexandra | 2006-07-10 09:47:06 | Aim of --enable-thread-safety ? |
Previous Message | DANTE Alexandra | 2006-07-10 09:26:52 | Re: VACUUM and fsm_max_pages |