Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 3D53663329F for ; Sat, 13 Feb 2010 03:06:36 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 10851-04 for ; Sat, 13 Feb 2010 07:06:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id B1DD663386C for ; Sat, 13 Feb 2010 03:06:25 -0400 (AST) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1NgC59-0004Dy-ET for pgsql-sql@postgresql.org; Sat, 13 Feb 2010 08:06:23 +0100 Received: from e177159073.adsl.alicedsl.de ([85.177.159.73]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 13 Feb 2010 08:06:23 +0100 Received: from tim by e177159073.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 13 Feb 2010 08:06:23 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: pgsql-sql@postgresql.org To: pgsql-sql@postgresql.org From: Tim Landscheidt Subject: Re: Can i force deletion of dependent rows? Date: Sat, 13 Feb 2010 07:05:59 +0000 Organization: Lines: 23 Message-ID: References: <6caee9521002120424l27ec8d3eq3b69522d0a773686@mail.gmail.com> <6caee9521002122211q7e4fd2fcj1a0489fd64dc204a@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: e177159073.adsl.alicedsl.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:Vo0MSG3FO+fv3DgqiOcGineQR4E= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/51 X-Sequence-Number: 33650 Shruthi A wrote: > I have 2 tables (A and B) where the table B has a foreign key reference to > table A. Like this: > create table A (x int primary key); > create table B (y int primary key, z int references A (x) ); > As you can see, i've not specified any further 'on delete' clause to the > foreign key constraint like 'on delete cascade' or 'on delete restrict' or > 'on delete set null' or 'on delete set default'. This means that the > default behavior is followed ie 'on delete restrict' holds by default. > Now I want to delete a particular row from table A. Is there any way I can > force deletion of all the dependent rows in table B? > Note that the tables have already been created in the above manner and > populated. I want to do this deletion through DML only ie without any > change in the table definition. "DELETE FROM B WHERE z = 'your x';"? Tim