Re: ALTER TABLE table DROP CONSTRAINT problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: lbergman(at)[nospam], abi(dot)tconline(dot)net(at)postgresql(dot)org
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: ALTER TABLE table DROP CONSTRAINT problem
Date: 2002-05-02 22:15:34
Message-ID: 18726.1020377734@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Lewis Bergman <lbergman(at)[nospam]abi(dot)tconline(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2002-05-02 22:40:45 Re: root of parent-child table with NOT NULL
Previous Message Terrence Brannon 2002-05-02 21:09:01 Re: non-root installation of Postgresql?