invisible dependencies on a table?

From: Tim Uckun <timuckun(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: invisible dependencies on a table?
Date: 2013-12-13 04:24:54
Message-ID: CAGuHJrPC4UCXRmsUUhnS0ykCdCPspv9TkKjg=OMCznyUuALZFQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2013-12-13 04:38:56 Re: invisible dependencies on a table?
Previous Message John Melesky 2013-12-12 19:17:47 Re: Zero dead tuples, when significant apparent bloat