Re: Delete across 5 Joined tables

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Fuzzygoth <dav(dot)phillips(at)ntlworld(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, braym(at)cromwell(dot)co(dot)uk
Subject: Re: Delete across 5 Joined tables
Date: 2008-08-17 20:44:45
Message-ID: 48A88DBD.2070701@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 15/08/2008 11:08, Fuzzygoth wrote:

> but I need to be able to delete from up to 5 different tables, is
> there a quick and
> simple way of doing this? can someone post an example?

Just guessing without more detailed information, but are the tables
related one-to-many using foreign keys? If so, when defining the foreign
key you can set the delete to cascade whenever a "master" row is deleted:

alter table foo
add constraint foo_fk foreign key [...]
on delete cascade;

...or something like that.

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kim Robinson 2008-08-18 05:28:22 Postres.exe Processes Hang
Previous Message Dmitry Koterov 2008-08-17 18:03:58 Open source PostgreSQL type parsers in PHP?