Re: drop constraint problem

From: "Joel Burton" <joel(at)joelburton(dot)com>
To: <Wolfgang(dot)Fuertbauer(at)ebewe(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: drop constraint problem
Date: 2002-05-21 13:10:10
Message-ID: JGEPJNMCKODMDHGOBKDNOEOICOAA.joel@joelburton.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

From the reference page for ALTER TABLE:

"Currently DROP CONSTRAINT drops only CHECK constraints. To remove FOREIGN
KEY constraints you need to recreate and reload the table, using other
parameters to the CREATE TABLE command."

However, I think the following is also safe:

create table p (id serial primary key);

create table c (id int);

alter table c add constraint c_ref_p foreign key (id) references p;

select * from pg_trigger;
-- look at actual names of trigger, above, and substitute below

drop trigger "RI_ConstraintTrigger_16573" on c;
drop trigger "RI_ConstraintTrigger_16575" on p;
drop trigger "RI_ConstraintTrigger_16577" on p;

Hope this helps. Some background on playing in the RI table is at
http://techdocs.postgresql.org/techdocs/hackingreferentialintegrity.php

Joel BURTON | joel(at)joelburton(dot)com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant

> -----Original Message-----
> From: pgsql-sql-owner(at)postgresql(dot)org
> [mailto:pgsql-sql-owner(at)postgresql(dot)org]On Behalf Of
> Wolfgang(dot)Fuertbauer(at)ebewe(dot)com
> Sent: Tuesday, May 21, 2002 3:13 AM
> To: pgsql-sql(at)postgresql(dot)org
> Subject: [SQL] drop constraint problem
>
>
>
> Hi all,
>
> i'm running 7.2.1 and have problems with dropping constraints:
>
> fakt32=# alter table wkfaktzeilen
> add constraint printjobfk foreign key (printjob)
> references wkfaktdruck(printjob)
> match full
> on delete cascade
> on update cascade;
> >ALTER
>
> fakt32=# alter table wkfaktzeilen drop constraint printjobfk restrict;
> >ERROR: ALTER TABLE / DROP CONSTRAINT: printjobfk does not exist
>
> fakt32=# alter table wkfaktdruck drop constraint printjobfk restrict;
> >ERROR: ALTER TABLE / DROP CONSTRAINT: printjobfk does not exist
>
> but when dropping the table, the triggers are deleted and i can see the
> entries
> in pg_triggers??
>
> please help
> Wolfgang
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2002-05-21 14:43:59 Re: constraints for ensuring relationships
Previous Message andre 2002-05-21 11:56:16 Re: Guarantee uniqueness of PGP key