Re: COPY with default values?

From: "Len Morgan" <len-morgan(at)crcom(dot)net>
To: "Jeff Boes" <jboes(at)nexcerpt(dot)com>, "Postgres-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: COPY with default values?
Date: 2001-05-25 14:24:34
Message-ID: 004701c0e526$79de3ea0$0908a8c0@H233.bstx.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I believe COPY is limited to reading ENTIRE records into a table not pieces
of them.

len morgan

-----Original Message-----
From: Jeff Boes <jboes(at)nexcerpt(dot)com>
To: Postgres-general <pgsql-general(at)postgresql(dot)org>
Date: Friday, May 25, 2001 9:20 AM
Subject: [GENERAL] COPY with default values?

>Let's say I have a table of keywords, with a SERIAL primary key.
>
>CREATE TABLE keywords (
> key_id SERIAL PRIMARY KEY,
> key_text TEXT
>);
>
>Now I would like to initialize this table with a COPY statement, but
>without supplying values for the primary key. In other words, how can I
>use COPY to perform the same function as
>
>INSERT INTO keywords (keyword_text) VALUES ('foo');
>INSERT INTO keywords (keyword_text) VALUES ('bar');
>...
>
>I have tried
>
>COPY keywords FROM stdin USING DELIMITERS '|';
>|foo
>|bar
>...
>
>and also
>
>0|foo
>0|bar
>
>and even
>
>\N|foo
>\N|bar
>
>I even tried creating a view on keywords that has only keyword_text, and
>copying into THAT--no luck. Then I wrote a rule to replace inserts on the
>view with inserts on the table, but apparently COPY doesn't trigger INSERT
>rules. Grumble...
>
>
>--
>Jeff Boes vox 616.226.9550
>Database Engineer fax 616.349.9076
>Nexcerpt, Inc. jboes(at)nexcerpt(dot)com
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
>http://www.postgresql.org/users-lounge/docs/faq.html
>

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-05-25 14:27:34 Re: Username with a hyphen character (grant failing?)
Previous Message Jeff Boes 2001-05-25 14:06:37 COPY with default values?