Does dropping a column from a table mess up foreign keys?

From: Keith F Irwin <kirwin14(at)home(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Does dropping a column from a table mess up foreign keys?
Date: 2001-07-20 19:13:11
Message-ID: Pine.LNX.4.33.0107201202360.6898-100000@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I'm getting the following error:

ERROR: Relation "accounts" with OID 72496 no longer exists

What I did was to drop a couple of columns using the example Bruce
provides in his book on page 264. Briefly, it's something like:

create table temp as select * from accounts;
drop table accounts;
create table accounts (etc with columns missing);
insert into accounts select <all except dropped cols> from temp;
drop table temp;
grant update,select,insert,delete on accounts to user;

And so on. I've also updated an "accounts_view" based on this table so
that the dropped columns wouldn't appear (the view being defined with an
asterisk field list).

I have lots of tables with "references accounts(id)" in them. Are these
going to be screwed up because of the drop/create above?

I even tried dumping the DB after the changes, then pg_restoring them, but
I get a message something like, Relation ACCOUNTS doesn't exist. I was
thinking that restoring the db in this way would recalculate the OIDs.

Is there some command I should do BEFORE the changes due to the fact that
other tables have contraints based on "accounts"? (Now that I think about
it, I'm amazed that I can drop a table with data dependent on it.)

Clues?

Keith

Browse pgsql-general by date

  From Date Subject
Next Message Travis Bauer 2001-07-20 19:57:20 InputStream as parameter not supported
Previous Message markMLl.pgsql-general 2001-07-20 19:02:37 Re: Migration