Re: fk constraint can't be dropped

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: "Zhang, Anna" <azhang(at)verisign(dot)com>
Cc: "'pgsql-admin(at)postgresql(dot)org'" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: fk constraint can't be dropped
Date: 2002-03-06 22:41:05
Message-ID: 20020306143636.K13015-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Wed, 6 Mar 2002, Zhang, Anna wrote:

> Hi,
> I created a foreign key constraint on table referral like this:
>
> alter table referral add constraint fk_referral foreign key (handle)
> references domain (handle);
> create
>
> alter table referral drop constraint fk_referral restrict;
> ERROR: ALTER TABLE / DROP CONSTRAINT: fk_referral does not exist.
>
> I am using postgres 7.2. If fk can't be dropped, what the synax: ALTER TABLE
> [ ONLY ] table DROP CONSTRAINT constraint { RESTRICT | CASCADE } for in
> docs? If we have to drop fk, does this mean we have to drop table and

The man page for alter table seems fairly explicit that drop constraint
only drops check constraints currently.

> recreate without fk? Stupid!

That's the easiest way. You could also drop the three triggers that
actually are the implementation of the constraint (which you can find
by looking into pg_trigger - look for triggers that have names like
RI_ConstraintTrigger_<numbers> that have appropriate the appropriate
name in tgconstrname and use drop trigger
"RI_ConstraintTrigger_<numbers>"; for each of them)

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Ian Barwick 2002-03-06 23:17:24 Re: Linux Distributions
Previous Message Chris Pesko 2002-03-06 22:25:20 production state?????/