From: | Gaetano Mendola <mendola(at)bigfoot(dot)com> |
---|---|
To: | Keith <siu_keith(at)hotmail(dot)com> |
Subject: | Re: add serial no |
Date: | 2004-08-24 21:07:09 |
Message-ID: | 412BADFD.5030903@bigfoot.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Crawford | 2004-08-24 21:48:42 | Re: add serial no |
Previous Message | andres barra | 2004-08-24 20:05:12 | HELP pleaseeee!!! |