Re: No serial type

Поиск
Список
Период
Сортировка
От Christian Schröder
Тема Re: No serial type
Дата
Msg-id 49234CC3.4030306@deriva.de
обсуждение исходный текст
Ответ на Re: No serial type  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Список pgsql-general
Scott Marlowe wrote:
> Serial is a "pseudotype".  It represents creating an int or bigint and
> a sequence then assigning a default value for the column and setting
> dependency in the db so the sequence will be dropped when the table
> gets dropped.  If you don't want to recreate the table, you can do
> this:
>
> create table a (i int primary key, info text);
> create sequence a_i_seq;
> alter table a alter column i set default nextval('a_i_seq');
>
You could even use "create sequence a_i_seq owned by a.i". This would
cause the sequence to be dropped when the table is dropped which I think
is the default behaviour if you create a column with type serial.

Regards,
    Christian

--
Deriva GmbH                         Tel.: +49 551 489500-42
Financial IT and Consulting         Fax:  +49 551 489500-91
Hans-Böckler-Straße 2                  http://www.deriva.de
D-37079 Göttingen

Deriva CA Certificate: http://www.deriva.de/deriva-ca.cer



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: apparent deadlock
Следующее
От: Erik Jones
Дата:
Сообщение: Re: No serial type