Re: changing the sequence for a table

From: Richard Huxton <dev(at)archonet(dot)com>
To: Cedric BRINER <work(at)infomaniak(dot)ch>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: changing the sequence for a table
Date: 2005-06-15 15:40:16
Message-ID: 42B04BE0.3060604@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Cedric BRINER wrote:
>
> the idea is to drop the ``old_test'' table. But before doing this,
> I'd like to alter the table ``test'' to use the sequence
> ``test_id_seq'' instead of ``test_new_seq_id''?

ALTER TABLE new_table ALTER COLUMN my_column DROP DEFAULT;
ALTER TABLE new_table ALTER COLUMN my_column SET DEFAULT
(nextval('old_seq'));
DROP TABLE old_table;

Or something along those lines. See "ALTER TABLE" in the manuals for
details.
--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Siebert 2005-06-15 15:45:09 vacuumdb suggestions?
Previous Message Zlatko Matic 2005-06-15 15:34:16 Re: users/users groups management from MS Access front-end