Re: going crazy with serial type

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Cindy <ctmoore(at)uci(dot)edu>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: going crazy with serial type
Date: 2002-01-31 20:51:19
Message-ID: 20020131124743.G16906-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Thu, 31 Jan 2002, Tom Lane wrote:

> Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2002-01-31 20:51:48 Re: going crazy with serial type
Previous Message Ellen Cyran 2002-01-31 20:51:09 Re: Function to Pivot data