Robert -- >Hi, > > >I have a column in a table called hist_id with the datatype "integer". When I >created the table I assigned this column the primary key constraint but didn´t >make it an auto-increment column. > > >How could I do this to an the already existing column? > > >I have created the sequence with the following command but don´t know how to >change the existing column to auto-increment. > > > > >$ create sequence hist_id_seq; >
Perhaps: ALTER TABLE history_foo ALTER COLUMN hist_id SET DEFAULT nextval('hist_id_seq'); ?? (untested) You may need to to update the sequence to reflect your current highest value for hist_id (or whatever the column is -- set the sequence using select setval('hist_id_seq', maxid) so that the next value you get from the sequence doesn't collide with existing values. HTH, Greg Williamson -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general