Re: Problem with COPY

From: "Christian Rengstl" <Christian(dot)Rengstl(at)klinik(dot)uni-regensburg(dot)de>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Problem with COPY
Date: 2006-07-11 07:24:06
Message-ID: 44B36E35.0AD0.0080.0@klinik.uni-regensburg.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi again everyone,

i got it to work, but came across another question concerning COPY. If i have a column in a text file that i do not want/need in the database, is there a way not to read that column from the file without having to edit the file beforehand?

Thanks for your advice!

"A. Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> wrote on 07/10/06 11:28 am:
> 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 majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Christian Rengstl M.A.
Klinik und Poliklinik für Innere Medizin II
Kardiologie - Forschung
Universitätsklinikum Regensburg
B3 1.388
Franz-Josef-Strauss-Allee 11
93053 Regensburg
Tel.: +49-941-944-7230

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Harald Armin Massa 2006-07-11 07:46:05 Re: Emergency - postgre is not working
Previous Message Alvaro Herrera 2006-07-11 05:27:49 Re: US Telephone Number Type