Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id BCD7863261E for ; Mon, 15 Feb 2010 15:03:32 -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 67330-03 for ; Mon, 15 Feb 2010 19:03:11 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) by mail.postgresql.org (Postfix) with ESMTP id 256FF63249C for ; Mon, 15 Feb 2010 15:03:22 -0400 (AST) Received: from in02.mta.xmission.com ([166.70.13.52]) by out02.mta.xmission.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Nh6E4-0004cL-14; Mon, 15 Feb 2010 12:03:20 -0700 Received: from [208.187.158.94] (helo=[172.16.1.222]) by in02.mta.xmission.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Nh6E3-00025O-R5; Mon, 15 Feb 2010 12:03:19 -0700 Message-ID: <4B799ABE.9040701@gmail.com> Date: Mon, 15 Feb 2010 12:04:30 -0700 From: Rob Sargent User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Can i force deletion of dependent rows? References: <6caee9521002120424l27ec8d3eq3b69522d0a773686@mail.gmail.com> <6caee9521002122211q7e4fd2fcj1a0489fd64dc204a@mail.gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-XM-SPF: eid=; ; ; mid=; ; ; hst=in02.mta.xmission.com; ; ; ip=208.187.158.94; ; ; frm=robjsargent@gmail.com; ; ; spf=neutral X-SA-Exim-Connect-IP: 208.187.158.94 X-SA-Exim-Mail-From: robjsargent@gmail.com X-SA-Exim-Scanned: No (on in02.mta.xmission.com); SAEximRunCond expanded to false X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.264 tagged_above=-10 required=5 tests=AWL=0.335, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/56 X-Sequence-Number: 33655 then I think OP needs to delete A where "your x"; On 02/13/2010 12:05 AM, Tim Landscheidt wrote: > 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 > >