changing the sequence for a table

From: Cedric BRINER <work(at)infomaniak(dot)ch>
To: pgsql-general(at)postgresql(dot)org
Subject: changing the sequence for a table
Date: 2005-06-15 16:05:30
Message-ID: 20050615160530.GI6788@obs.unige.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hi,

let me explain what I have done, and what I'd like to do with a small example:

create table test (id serial, nom varchar(32));
INSERT INTO test ("nom") values ('cedric');
INSERT INTO test ("nom") values ('felix');
INSERT INTO test ("nom") values ('julien');

create table new_test (id serial, nom varchar(32));
insert into new_test SELECT * from test;

ALTER TABLE test RENAME to old_test;
ALTER TABLE new_test RENAME to test;

SELECT * from test_id_seq;
SELECT * from new_test_id_seq;
we can see that the two last select doesn't give the same value.

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''?

can I do this ???
please tell me yes, but after all the me how ! : )

Ced.
--

Cedric BRINER

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Berend Tober 2005-06-15 16:08:22 Re: enebling regular user to create new users ?
Previous Message Richard Huxton 2005-06-15 15:57:14 Re: enebling regular user to create new users ?