Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 129016326D5 for ; Sat, 13 Feb 2010 07:32:51 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 50931-08 for ; Sat, 13 Feb 2010 11:32:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f222.google.com (mail-bw0-f222.google.com [209.85.218.222]) by mail.postgresql.org (Postfix) with ESMTP id 671F4632319 for ; Sat, 13 Feb 2010 07:32:39 -0400 (AST) Received: by bwz22 with SMTP id 22so128940bwz.21 for ; Sat, 13 Feb 2010 03:32:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=qBd9vcqZVQMxK54cGhltxmgJDscFFmPORtCfm+llVZI=; b=kx9NqFwJv5Z0o1dzL+ILZmkrlFV+rP2K9La1hn/JAzTmRxUKT4jFnRS4Zvsuqj6ajz MLt0NFXILWrwINnEpdvKcwBTINWnSik5MiqBamOOHZbVKU10aLkaVXglxrcwQYisGmVr L6G/48Cwbg/zOVsZBtkqQk2+XmBcB47EnnT4g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=pycrCOB1JLHMnMchmO6ON1e/iHpENapxHf4LtMelmbqKb6AylyNYVhYQZXzcQV9vFP RnZE4gDW72rLXzdfDt5ewYmqepRt9HQb8ymskuomtSg/N+4rt9Q2lPPPx6mxaQ4UekYz sfrBId9o4AoGwdFz4xbNyoJBzs/wz39D24Dok= MIME-Version: 1.0 Received: by 10.204.151.217 with SMTP id d25mr1701513bkw.24.1266060756991; Sat, 13 Feb 2010 03:32:36 -0800 (PST) In-Reply-To: References: <6caee9521002120424l27ec8d3eq3b69522d0a773686@mail.gmail.com> <6caee9521002122211q7e4fd2fcj1a0489fd64dc204a@mail.gmail.com> Date: Sat, 13 Feb 2010 22:32:36 +1100 Message-ID: Subject: Re: Can i force deletion of dependent rows? From: Shoaib Mir To: "Wayne E. Seguin" Cc: pgsql-sql@postgresql.org Content-Type: multipart/alternative; boundary=0015175def9aaf3f68047f79bd87 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.544 tagged_above=-10 required=5 tests=AWL=-0.435, BAYES_05=-1.11, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201002/53 X-Sequence-Number: 33652 --0015175def9aaf3f68047f79bd87 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Feb 13, 2010 at 10:23 PM, Wayne E. Seguin wrote: > Is there another answer, asside from in the application and/or as a > trigger using `DELETE FROM B WHERE z = 'x';` as it's body? > > > Did you look at ON DELETE CASCADE option, check out http://www.postgresql.org/docs/8.3/interactive/ddl-constraints.html CREATE TABLE order_items ( product_no integer REFERENCES products *ON DELETE RESTRICT*, order_id integer REFERENCES orders *ON DELETE CASCADE*, quantity integer, PRIMARY KEY (product_no, order_id) ); -- Shoaib Mir http://shoaibmir.wordpress.com/ --0015175def9aaf3f68047f79bd87 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Sat, Feb 13, 2010 at 10:23 PM, Wayne E. Seguin <wayneeseguin@gmail.com> wrote:
Is there another answer, asside from in the application and/or as a
trigger using `DELETE FROM B WHERE z =3D 'x';` as it's body?


Did you look at ON DELETE CASCADE = option, check out=A0http://www.postgresql.org/docs/8.3/interactive/ddl= -constraints.html=A0

CREATE TABLE order_items (
    product_no integer REFERENCES products ON DELETE RESTRICT,
    order_id integer REFERENCES orders ON DELETE CASCADE,
    quantity integer,
    PRIMARY KEY (product_no, order_id)=A0
http://shoaibmir.wordpress.com/
--0015175def9aaf3f68047f79bd87--