Re: Best way to create unique primary keys across schemas?

Поиск
Список
Период
Сортировка
От Chris Angelico
Тема Re: Best way to create unique primary keys across schemas?
Дата
Msg-id CAPTjJmqKRNBpPAh9PbwOAjhLYjyzThZ=t4bx1FOaZjQkO5o5=A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Best way to create unique primary keys across schemas?  (panam <panam@gmx.net>)
Ответы Re: Best way to create unique primary keys across schemas?  (panam <panam@gmx.net>)
Список pgsql-general
On Wed, Jan 25, 2012 at 9:54 AM, panam <panam@gmx.net> wrote:
> What do you mean with "explicit sequence object"? An own sequence for each
> table per schema?

This:

On Wed, Jan 25, 2012 at 10:23 AM, Merlin Moncure <mmoncure@gmail.com> wrote:
> Barring domains, you can just manually apply the default instead of
> using a serial type:
>
> create table foo (gid bigint default nextval('global_seq'));

http://www.postgresql.org/docs/9.1/static/sql-createsequence.html

When you create a 'serial' column, Postgres creates a sequence and
makes the column as 'int' with a default that pulls from the sequence.
(Similarly for 'bigserial' and 'bigint'.) If you create the sequence
yourself, you get a bit more control over it (eg setting
min/max/step), and can name it appropriately.

Note the OWNED BY clause (as documented in the above link). That's
what I was saying about the sequence being owned by or linked to the
creating table.

ChrisA

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

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: any plans to support more rounding methods in sql?
Следующее
От: Jason Armstrong
Дата:
Сообщение: Index on parent/child hierarchy