Re: Help with pre-loaded arbitrary key sequences - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Help with pre-loaded arbitrary key sequences
Date
Msg-id 20080116134236.GA27832@svana.org
Whole thread Raw
In response to Help with pre-loaded arbitrary key sequences  ("James B. Byrne" <byrnejb@harte-lyne.ca>)
List 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@svana.org>   http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
>  -- John F Kennedy

Attachment

pgsql-general by date:

Previous
From: "R.A."
Date:
Subject: Re: Can I create a TYPE (or DOMAIN) with arguments?
Next
From: Csaba Nagy
Date:
Subject: Re: varchar sort ordering ignore blanks