Re: auto fill serial id field with default value in copy operation

From: "karsten vennemann" <karsten(at)terragis(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: auto fill serial id field with default value in copy operation
Date: 2010-10-22 22:29:48
Message-ID: C3897787B4614F0083F1B49D168AED68@snuggie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yes it worked when I ommited the serial field in the copy command (and in
the import source file). As a reference for others:

COPY records (quad_id, species_id, observation_value) from
'/var/www/data/data_import2.csv' using delimiters ',' with null as '';

Karsten

> -----Original Message-----
> From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
> Sent: Friday, October 22, 2010 14:31
> To: karsten vennemann
> Cc: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] auto fill serial id field with default
> value in copy operation
>
> "karsten vennemann" <karsten(at)terragis(dot)net> writes:
> > What is the best way to load my data via copy into the db
> and get the record_id field auto filled (with the next id
> value in squence) ?
>
> You have to omit the column from the copy data altogether,
> and then list just the columns that are supplied in the data
> in the COPY command's column list.
>
> regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alexia Lau 2010-10-23 02:00:20 Re: Missing uuid_generate_v1()
Previous Message ljb 2010-10-22 22:06:07 Re: Gripe: bytea_output default => data corruption