Skip site navigation (1) Skip section navigation (2)

Re: bulk imports with sequence

From: "Dan Langille" <dan(at)langille(dot)org>
To: "Aaron Held" <aaron(at)metrony(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: bulk imports with sequence
Date: 2002-08-20 12:00:28
Message-ID: 3D61F71C.23211.5F25BAFB@localhost (view raw or flat)
Thread:
Lists: pgsql-sql
On 20 Aug 2002 at 7:55, Aaron Held wrote:

> I am importing a large number of records monthly using the \copy (from
> text file)command.
> 
> I would like to use a sequence as a unique row ID for display in my
> app.
> 
> Is there any way to let postgresql generate the sequence itself. 
> Currently the only way I can make it work is to grab the next seq
> value and insert my own numbers into the file

Yes: 

create sequence mytable_id_seq;
alter table mytable alter column id set default 
nextval('mycolumn_id_seq'::text);
-- 
Dan Langille
I'm looking for a computer job:
http://www.freebsddiary.org/dan_langille.php


In response to

pgsql-sql by date

Next:From: Darrin DomoneyDate: 2002-08-20 13:15:48
Subject: Event recurrence - in database or in application code ????
Previous:From: Aaron HeldDate: 2002-08-20 11:55:24
Subject: bulk imports with sequence

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group