Re: recreating table and foreign keys

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Tomasz Myrta <jasiek(at)klaster(dot)net>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: recreating table and foreign keys
Date: 2002-12-03 19:55:58
Message-ID: 20021203115400.X73093-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Tue, 3 Dec 2002, Tomasz Myrta wrote:

> > You'll probably end up using ALTER TABLE ADD CONSTRAINT to add the
> > constraints to the new master_table. It's possible that you might
> > be able to hack something with the system tables, but that sounds
> > dangerous. Or you can upgrade to 7.3 which lets you run alter table
> > drop column. :)
> If it is the only way, I can create >20 "alter table add constraint...", but
> is rather a boring finish :-(
> I found, I can dump database - data only. After this I can create all tables
> and restore data.

Yeah, dump and restore is generally a pretty big thing though.

> Any other solution?

You might be able to write a function that would duplicate constraints
from the table you want to dispose of to the new table, but it might be
hairy. If you do this alot, you might want to upgrade to 7.3 (which
requires one dump and reload).

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message mark carew 2002-12-03 20:49:59 Re: import sql script
Previous Message Jean-Luc Lachance 2002-12-03 19:53:06 Re: Query for filtering records