Re: Are JOINs allowed with DELETE FROM

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Are JOINs allowed with DELETE FROM
Дата
Msg-id 20050206175029.GA89095@winnie.fuhr.org
обсуждение исходный текст
Ответ на Are JOINs allowed with DELETE FROM  (Steven Rosenstein <srosenst@us.ibm.com>)
Ответы Re: Are JOINs allowed with DELETE FROM  (Steven Rosenstein <srosenst@us.ibm.com>)
Список 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 по дате отправления:

Предыдущее
От: Gaetano Mendola
Дата:
Сообщение: Re: Are JOINs allowed with DELETE FROM
Следующее
От: John Arbash Meinel
Дата:
Сообщение: Re: Are JOINs allowed with DELETE FROM