Sunday, August 17, 2008

Re: [GENERAL] Delete across 5 Joined tables

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@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

No comments: