Re: add serial no

Поиск
Список
Период
Сортировка
От Gaetano Mendola
Тема Re: add serial no
Дата
Msg-id 412BADFD.5030903@bigfoot.com
обсуждение исходный текст
Ответ на add serial no  ("Keith" <siu_keith@hotmail.com>)
Список pgsql-admin
Keith wrote:

> Dear All,
>
> Someone can help me to solve the below problems
>
> 1. I create a table for a period of time, there is huge records already
> posted.
> I would like to alter table and add serial primary key on that table.
> It's impossible to add serial no by hand. Please adv  how can I add the
> serial number automatically.


Just to inform you that with the future 8.0 postgresl version you can
do this task easily:

kalman=# select * from test;field_1
---------      3      5      7      6      8
(5 rows)

kalman=# alter table test add column pk serial primary key;
NOTICE:  ALTER TABLE will create implicit sequence "test_pk_seq" for serial column "test.pk"
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "test_pkey" for table "test"
ALTER TABLE
kalman=# select * from test;field_1 | pk
---------+----      3 |  1      5 |  2      7 |  3      6 |  4      8 |  5
(5 rows)




Regards
Gaetano Mendola









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

Предыдущее
От: "andres barra"
Дата:
Сообщение: HELP pleaseeee!!!
Следующее
От: Steve Crawford
Дата:
Сообщение: Re: add serial no