Re: Drop foreign keys

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Andreas Schlegel <schlegelaw(at)gmx(dot)de>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Drop foreign keys
Date: 2003-01-08 16:07:30
Message-ID: 20030108080539.S76148-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 8 Jan 2003, Andreas Schlegel wrote:

> Hi,
>
> I created some references with foreign keys. But now I have to drop
> some of the references. What is the way to do this? Is there a command
> for this? Or have I drop the table and recreate it?
> Postgres gave the references names like "RI_ConstraintTrigger_494516".
> If there is a way to drop them one by one how do I get the information
> on which foreign key point these Postgres names?
>
> All references are created like this:
> ... constraint tPerson_FK03 foreign key (titel)
> references tTitel (tnr)
> ON UPDATE CASCADE ON DELETE RESTRICT ...

What version are you using?
In 7.3, you should be able to say
ALTER TABLE <table> DROP CONSTRAINT tPerson_FK03;

In previous versions, you'll need to manually drop the
three triggers that are created (you can find the correct
triggers by looking for tgconstrname='tPerson_FK03') and
you'll need to double quote the tgname for DROP TRIGGER
commands.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Johnson, Shaunn 2003-01-08 16:10:18 tracking down breakins?
Previous Message John Chapman 2003-01-08 14:42:24 Re: Strange Error