pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frank Joerdens <frank@joerdens.de>
To: pgsql-sql@postgresql.org
Subject: How to drop an <unnamed> trigger
Date: Thu, 8 Mar 2001 16:42:46 +0100
Message-ID: <20010308164246.A16533@rakete.joerdens.de> (raw)

I've created quite a few foreign key constraints in the database that I
am currently working on, and now that I've altered the structure and
dropped a table that had a foreign key reference to a couple of other
tables, I need to get rid of those foreign keys (they weren't dropped
automagically with the table), as I get errors on trying to update those
tables.

Trouble is that the foreign keys show up in a schema dump as <unnamed>
triggers (AFAIK there is no other way to display foreign key
constraints) which I don't know how to drop. Here's an example:

\connect - frank
--
-- TOC Entry ID 56 (OID 52367)
--
-- Name: "RI_ConstraintTrigger_52366" Type: TRIGGER Owner: frank
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "index"  NOT
DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE
"RI_FKey_cascade_del" ('<unnamed>', 'legende', 'index', 'UNSPECIFIED',
'platz', 'id');

I tried dropping it with 

=# drop trigger RI_ConstraintTrigger_52366 on index;

which fails with

ERROR:  DropTrigger: there is no trigger ri_constrainttrigger_52366 on
relation index

What to do? And more broadly, what's the recommended way to deal with
this in general? Avoid creating <unnamed> triggers by always creating named
foreign keys with something like

ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address)
REFERENCES addresses(address) MATCH FULL;

(from Bruce's book)?

Regards, Frank



view thread (4+ messages)  latest in thread

Message-ID: <20010308164246.A16533@rakete.joerdens.de>
Permalink:  ../20010308164246.A16533@rakete.joerdens.de/
Also on:    postgresql.org/message-id/20010308164246.A16533@rakete.joerdens.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: frank@joerdens.de
  Subject: Re: How to drop an <unnamed> trigger
  In-Reply-To: <20010308164246.A16533@rakete.joerdens.de>
  References: <20010308164246.A16533@rakete.joerdens.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox