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