REQUEST: option to auto-generate new sequences with CREATE TABLE (LIKE)

Started by Nico Sabbiover 18 years ago2 messagesgeneral
Jump to latest
#1Nico Sabbi
nsabbi@officinedigitali.it

Hi,
as the subjects reads I searched in the docs a way to instruct postgres
to create new sequences when copying tables containing serial columns,
but the resulting serial fields in the new tables reference the
original sequence.

Yes, there are workarounds, but having an option to make postgres
automatically
generate a new sequence for every serial field would be splendid.

I hope you will consider this feature for one of the future versions of
Postgres.

Thanks,
Nico

#2David Fetter
david@fetter.org
In reply to: Nico Sabbi (#1)
Re: REQUEST: option to auto-generate new sequences with CREATE TABLE (LIKE)

On Wed, Jul 18, 2007 at 03:10:30PM +0200, Nico Sabbi wrote:

Hi,
as the subjects reads I searched in the docs a way to instruct postgres
to create new sequences when copying tables containing serial columns,
but the resulting serial fields in the new tables reference the
original sequence.

That's the right behavior. You should be using

pg_get_serial_sequence('your_table','your_column')

to get the sequence name anyhow. :)

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate