pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Steven Rosenstein <srosenst@us.ibm.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Are JOINs allowed with DELETE FROM
Date: Sun, 6 Feb 2005 10:50:29 -0700
Message-ID: <20050206175029.GA89095@winnie.fuhr.org> (raw)
In-Reply-To: <OF545A271F.B5FD775B-ON85256FA0.005EC116-85256FA0.005EDEB5@us.ibm.com>
References: <OF545A271F.B5FD775B-ON85256FA0.005EC116-85256FA0.005EDEB5@us.ibm.com>

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/



view thread (8+ messages)  latest in thread

Message-ID: <20050206175029.GA89095@winnie.fuhr.org>
Permalink:  ../20050206175029.GA89095@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20050206175029.GA89095@winnie.fuhr.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: mike@fuhr.org, srosenst@us.ibm.com
  Subject: Re: Are JOINs allowed with DELETE FROM
  In-Reply-To: <20050206175029.GA89095@winnie.fuhr.org>

* 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