Re: Importing data - Mailing list pgsql-general

From nconway@klamath.dyndns.org (Neil Conway)
Subject Re: Importing data
Date
Msg-id 20020729174912.GA8396@klamath.dyndns.org
Whole thread Raw
In response to Importing data  (Patrick Nelson <pnelson@neatech.com>)
List pgsql-general
On Mon, Jul 29, 2002 at 10:34:31AM -0700, Patrick Nelson wrote:
>   COPY mss FROM '/subset.csv' USING DELIMITERS ',';
>
> Which imports a file like:
>
>   ,1,SLWS,SLWS DATA,$489.18M,6,1,1,0,0,8,1.37,Sat Jun 29 12:42:47 PDT 2002
>   ,2,SRDE,SRDE DATA,$232.30M,0,0,2,0,0,2,3,Sat Jun 29 12:43:00 PDT 2002
>   ...
>
> However, id doesn't get populated with a sequence of numbers.  Note that the
> 1 and 2 of the above import file is being properly dumped into ind, even
> though I have to add "," to the beginning of each line.  So I think that I
> don't really get it.

If data for an attribute is missing, it will be set to NULL in 7.2 and
earlier versions of PostgreSQL. This behavior will be fixed in 7.3, but
until then, you can set the "id" column yourself:

COPY ...;
UPDATE mss SET id = nextval('mss_id_seq');

Cheers,

Neil

--
Neil Conway <neilconway@rogers.com>
PGP Key ID: DB3C29FC

pgsql-general by date:

Previous
From: Patrick Nelson
Date:
Subject: Importing data
Next
From: Robert Treat
Date:
Subject: Re: phpPgAdmin problem