Re: Sequence vs Serial - Mailing list pgsql-sql

From Tom Lane
Subject Re: Sequence vs Serial
Date
Msg-id 16016.1175453510@sss.pgh.pa.us
Whole thread Raw
In response to Re: Sequence vs Serial  (Scott Marlowe <smarlowe@g2switchworks.com>)
List pgsql-sql
Scott Marlowe <smarlowe@g2switchworks.com> writes:
> Daniel CAUNE <d.caune@free.fr> Said:
>> I was wondering when it is better to choose sequence, and when 
>> it is better to use serial.

> One reason for using serial versus sequence is that a serial gives you
> automatic dependency tracking.

Note that as of 8.2, with the introduction of ALTER SEQUENCE OWNED BY,
you can manipulate the column-to-sequence dependency by hand.  This
means there really is no difference between starting from a separate
sequence and starting with a "serial" column declaration --- you can get
to all the same database states either way.

I tend to think that it's best to use a serial if you intend only the
one column to use the sequence generator, whereas if you intend multiple
columns to be fed from the same sequence generator you ought to declare
the sequence as a freestanding object to start with.  But it's just a
question of style.
        regards, tom lane


pgsql-sql by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: Sequence vs Serial
Next
From: Peter Eisentraut
Date:
Subject: Calling void functions