Re: Equivalent for AUTOINCREMENT?

Поиск
Список
Период
Сортировка
От Albe Laurenz
Тема Re: Equivalent for AUTOINCREMENT?
Дата
Msg-id D960CB61B694CF459DCFB4B0128514C202ACF95D@exadv11.host.magwien.gv.at
обсуждение исходный текст
Ответ на Re: Equivalent for AUTOINCREMENT?  (Michelle Konzack <linux4michelle@tamay-dogan.net>)
Список pgsql-general
Michelle Konzack wrote:
> > I think you want a sequence. Give the serial number the type
bigserial or
> > serial.  See
> >
http://www.postgresql.org/docs/current/static/functions-sequence.html
for
> > more.
>
> OK, thats cool...  I have found an example in
"sql-createsequence.html"
>
> CREATE SEQUENCE serial START 1;
>
> INSERT INTO distributors VALUES (nextval('serial'), 'nothing');
>
> But there is one thing not clear:
>
> Du I need to create a SEQUENCE for each table or do I need only  ONE
of
> if and can use it independant on differnt tables?

You can use one sequence for many tables.

If you follow the advice by Nikolas Everett and use a "serial" column,
that would create one dedicated sequence per serial column.

Yours,
Laurenz Albe

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

Предыдущее
От: "Willy-Bas Loos"
Дата:
Сообщение: [pgsql-general] cant find postgres executable after initdb
Следующее
От: "Albe Laurenz"
Дата:
Сообщение: Re: COPY TO duplicates "\" signs