Re: Help with pre-loaded arbitrary key sequences

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: "James B(dot) Byrne" <byrnejb(at)harte-lyne(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Help with pre-loaded arbitrary key sequences
Date: 2008-01-16 13:42:36
Message-ID: 20080116134236.GA27832@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jan 11, 2008 at 11:43:54AM -0500, James B. Byrne wrote:
> My question is this: Can one assign an id number to a sequenced key column
> on create and override the sequencer? If one does this then can and, if
> so, how does the sequencer in Postgresql handle the eventuality of running
> into a block of keys holding previously assigned numbers?

You can set the counter during create, or at any time later. However,
the counter is not defined by the column as such and will happily
return numbers already in the table if you screw it up.

The usual process is to insert normally when loading the data and then
do a setval() on the sequence to past the values already stored.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
> -- John F Kennedy

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Csaba Nagy 2008-01-16 13:43:49 Re: varchar sort ordering ignore blanks
Previous Message R.A. 2008-01-16 13:21:29 Re: Can I create a TYPE (or DOMAIN) with arguments?