Re: going crazy with serial type - Mailing list pgsql-general

From Stephan Szabo
Subject Re: going crazy with serial type
Date
Msg-id 20020131124743.G16906-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: going crazy with serial type  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Thu, 31 Jan 2002, Tom Lane wrote:

> Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
> > You won't get that.  serial (and sequences) are guaranteed to give numbers
> > that haven't shown up in the sequence (note: you can still get duplicates
> > if you set values yourself, you can get around this with triggers -
>
> The SERIAL type implicitly adds a UNIQUE index, so you don't need to
> worry about uniqueness even if you sometimes manually insert values.

Right, but you get the intermittent errors in that case since the serial
doesn't skip the values that would error (which you might expect if you're
guaranteeing distinct numbers in a column).  When looked at as what it is
(an integer with a default) it makes sense, but if you don't know that
it's a bit unexpected.



pgsql-general by date:

Previous
From: Jason Earl
Date:
Subject: Re: going crazy with serial type
Next
From: "Gregory Wood"
Date:
Subject: Re: going crazy with serial type