Re: Sequence vs Serial
От
Tom Lane
Тема
Re: Sequence vs Serial
Дата
Msg-id
16016.1175453510@sss.pgh.pa.us
Ответ на
Re: Sequence vs Serial (Scott Marlowe)
Список
Дерево обсуждения
Sequence vs Serial Daniel CAUNE <d.caune@free.fr>
Re: Sequence vs Serial Scott Marlowe <smarlowe@g2switchworks.com>
Re: Sequence vs Serial Tom Lane <tgl@sss.pgh.pa.us>
Scott Marlowe writes: > Daniel CAUNE 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 по дате отправления