Re: sequence - Mailing list pgsql-novice

From Manuel Sugawara
Subject Re: sequence
Date
Msg-id m31xla38vx.fsf@conexa.fciencias.unam.mx
Whole thread Raw
In response to sequence  (Robert Morgan <robert_@ihug.co.nz>)
List pgsql-novice
Robert Morgan <robert_@ihug.co.nz> writes:

> Do I need to drop the existing column and create a new one using
> create sequence.....?

No, or at least not necessarily. You can create the sequence and then
alter the existing column definition to get its default value from
that sequence, for instance, suppose that your table name is foo and
the column's name is bar:

create sequence new_seq;
select setval('new_seq', select max(bar) from foo);
alter table foo alter column bar set default nextval(new_seq');

Regards,
Manuel.

pgsql-novice by date:

Previous
From:
Date:
Subject: Re: phppgadmin on Debian/unstable (sort of)
Next
From: "Rajan Bhide"
Date:
Subject: Re: !!URGENT!! Should I keep INDEX on the table?