Re: Are JOINs allowed with DELETE FROM - Mailing list pgsql-performance

From Michael Fuhr
Subject Re: Are JOINs allowed with DELETE FROM
Date
Msg-id 20050206175029.GA89095@winnie.fuhr.org
Whole thread Raw
In response to Are JOINs allowed with DELETE FROM  (Steven Rosenstein <srosenst@us.ibm.com>)
Responses Re: Are JOINs allowed with DELETE FROM
List pgsql-performance
On Sun, Feb 06, 2005 at 12:16:13PM -0500, Steven Rosenstein wrote:
>
> DELETE FROM detail JOIN summary ON (summary.id=detail.sum_id) WHERE
> collect_date='2005-02-05';
>
> But I keep getting a parser error.  Am I not allowed to use JOINs in a
> DELETE statement, or am I just fat-fingering the SQL text somewhere.

See the documentation for DELETE:

http://www.postgresql.org/docs/8.0/static/sql-delete.html

If you intend to delete the date's record from the summary table,
then the detail table could use a foreign key constraint defined
with ON DELETE CASCADE.  Deleting a record from summary would then
automatically delete all associated records in detail.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-performance by date:

Previous
From: Gaetano Mendola
Date:
Subject: Re: Are JOINs allowed with DELETE FROM
Next
From: John Arbash Meinel
Date:
Subject: Re: Are JOINs allowed with DELETE FROM