Re: ALTER TABLE table DROP CONSTRAINT problem - Mailing list pgsql-novice

From Tom Lane
Subject Re: ALTER TABLE table DROP CONSTRAINT problem
Date
Msg-id 18726.1020377734@sss.pgh.pa.us
Whole thread Raw
In response to ALTER TABLE table DROP CONSTRAINT problem  (Lewis Bergman <lbergman@[nospam] abi.tconline.net>)
List pgsql-novice
Lewis Bergman <lbergman@[nospam]abi.tconline.net> writes:
> I am trying to drop a constraint that was set up by this SQL
> ALTER TABLE customer_main ADD CONSTRAINT cust_main_agent
>   FOREIGN KEY ( agent )
>    REFERENCES customer_main ( id )
>     NOT DEFERRABLE;

> So I do this:
> ALTER TABLE customer_main DROP CONSTRAINT cust_main_agent RESTRICT;
> And get this error:
> ERROR:  ALTER TABLE / DROP CONSTRAINT: cust_main_agent does not exist

AFAIK, the current implementation of DROP CONSTRAINT only supports
dropping CHECK constraints; it gives you that error because it doesn't
find anything about cust_main_agent in the check-constraint table.

You can manually drop a foreign-key constraint by dropping the three or
so triggers that implement it.  I forget the details but they're in the
list archives.

There will probably be a cleaner way to do it in a release or two...

            regards, tom lane

pgsql-novice by date:

Previous
From: Terrence Brannon
Date:
Subject: Re: non-root installation of Postgresql?
Next
From: "Josh Berkus"
Date:
Subject: Re: root of parent-child table with NOT NULL