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









---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to