pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dan Langille <dan@langille.org>
To: Aaron Held <aaron@metrony.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: bulk imports with sequence
Date: Tue, 20 Aug 2002 08:00:28 -0400
Message-ID: <3D61F71C.23211.5F25BAFB@localhost> (raw)
In-Reply-To: <000b01c24840$7b5a0880$4b00a8c0@metrony.com>

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




view thread (3+ messages)  latest in thread

Message-ID: <3D61F71C.23211.5F25BAFB@localhost>
Permalink:  ../3D61F71C.23211.5F25BAFB@localhost/
Also on:    postgresql.org/message-id/3D61F71C.23211.5F25BAFB@localhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dan@langille.org, aaron@metrony.com
  Subject: Re: bulk imports with sequence
  In-Reply-To: <3D61F71C.23211.5F25BAFB@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox