Re: serial, sequence, and COPY FROM - Mailing list pgsql-general

From Michael Fuhr
Subject Re: serial, sequence, and COPY FROM
Date
Msg-id 20060912192220.GA57867@winnie.fuhr.org
Whole thread Raw
In response to Re: serial, sequence, and COPY FROM  ("Brandon Aiken" <BAiken@winemantech.com>)
List pgsql-general
On Tue, Sep 12, 2006 at 02:48:30PM -0400, Brandon Aiken wrote:
> Serial fields have a default value of nextval, so if you add an 18th
> field to your text file with DEFAULT in every record it should work as
> intended.

DEFAULT works with INSERT but not with COPY:

test=> CREATE TABLE foo (col1 integer, col2 integer, col3 serial);
NOTICE:  CREATE TABLE will create implicit sequence "foo_col3_seq" for serial column "foo.col3"
CREATE TABLE
test=>  COPY foo FROM stdin DELIMITER '|';
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> 1|2|DEFAULT
>> \.
ERROR:  invalid input syntax for integer: "DEFAULT"
CONTEXT:  COPY foo, line 1, column col3: "DEFAULT"

--
Michael Fuhr

pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: serial, sequence, and COPY FROM
Next
From: Zlatko Matić
Date:
Subject: program for graphical/schematical representation of relations between tables