Re: Adding Foreign Key Constraint To Existing Table

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Adding Foreign Key Constraint To Existing Table
Date: 2011-07-01 22:04:44
Message-ID: alpine.LNX.2.00.1107011502460.31349@salmo.appl-ecosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 1 Jul 2011, Thom Brown wrote:

> By the way, rather than dropping the foreign key then recreating it, you
> could always do this:
>
> ALTER TABLE tablename DISABLE TRIGGER ALL;
>
> Then it would ignore the foreign key trigger and you could put in
> mischievous values... but remember to enable it again (replace DISABLE
> with ENABLE). You'll have to be a superuser to do it though.

Thom,

Valuable information, thanks. I try to get the table structure correct
before loading it into a database. In this case I was copying structure
(with minor mods) from an existing environmental database and it took me a
while to notice the original authors used synthetic keys when they are not
needed. So, I got rid of those keys.

Rich

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-07-02 00:28:02 Re: Adding Foreign Key Constraint To Existing Table
Previous Message Thom Brown 2011-07-01 21:42:08 Re: Adding Foreign Key Constraint To Existing Table