I have a table foo. It has a serial column called "id". I execute the following statement
ALTER TABLE table_name RENAME TO archived_table_name;
CREATE TABLE table_name (LIKE archived_table_name INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING INDEXES);
..... Archieve the table here...
DROP TABLE arhived_table_name
This doesn't work because the archived table name has a dependency on the sequence created by the serial field. So I try to remove that dependency by doing this.
alter table "archived_table_name" alter column id drop default;
ALTER TABLE"archived_table_name" DROP CONSTRAINT systemevents_pkey;
So by now there should not be a dependency on the sequence but I still can't drop the table and and pgadmin tells me it's still depending on the sequence.
When I look at the table definition it doesn't seem to have any reference to the sequence at all.
How can I drop this table and leave the sequence alone? Obviously the newly created table needs it.
Thanks.