Re: Importing data

From: nconway(at)klamath(dot)dyndns(dot)org (Neil Conway)
To: Patrick Nelson <pnelson(at)neatech(dot)com>
Cc: "PostgreSQL List (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Importing data
Date: 2002-07-29 17:49:12
Message-ID: 20020729174912.GA8396@klamath.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)rogers(dot)com>
PGP Key ID: DB3C29FC

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert Treat 2002-07-29 17:54:42 Re: phpPgAdmin problem
Previous Message Patrick Nelson 2002-07-29 17:34:31 Importing data