Re: auto-increment column

Поиск
Список
Период
Сортировка
От Joe Abbate
Тема Re: auto-increment column
Дата
Msg-id 4E8B0199.6000203@freedomcircle.com
обсуждение исходный текст
Ответ на Re: auto-increment column  (Robert Buckley <robertdbuckley@yahoo.com>)
Список pgsql-general
On 10/04/2011 08:05 AM, Robert Buckley wrote:
> Thanks for the replies,
>
> I have one question regarding this comment...
>
> "You also need to add a DEFAULT expression and optionally
> make the sequence owned by the column:"
>
> What difference does it make if a table "owns" a sequence of not?...does
> this contraint the use of the sequence to ONLY that one table?
>
> The sequence will only be used to auto-increment the id column in order
> to have an automatic primary key. Could I then somehow use the sequence
> for all tables which need this?

Making the table own the sequence causes the sequence to be dropped if
the table is dropped.  Making the sequence owned by the table happens
automatically if you had originally created the column with SERIAL
instead of adding the sequence with ALTER TABLE, but is not entirely
necessary.

That said, I'd think twice before using a sequence for more than one
table (unless they were part of an inheritance/partitioning scheme).

Joe

В списке pgsql-general по дате отправления:

Предыдущее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: PG Source Compilation (Optional Features / Optional Packages)
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: How can i get record by data block not by sql?