pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Can i force deletion of dependent rows?
Date: Mon, 15 Feb 2010 12:04:30 -0700
Message-ID: <4B799ABE.9040701@gmail.com> (raw)
In-Reply-To: <m3fx55linc.fsf@passepartout.tim-landscheidt.de>
References: <6caee9521002120424l27ec8d3eq3b69522d0a773686@mail.gmail.com>
	<6caee9521002122211q7e4fd2fcj1a0489fd64dc204a@mail.gmail.com>
	<m3fx55linc.fsf@passepartout.tim-landscheidt.de>

then I think OP needs to delete A where "your x";

On 02/13/2010 12:05 AM, Tim Landscheidt wrote:
> Shruthi A<shruthi.iisc@gmail.com>  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
>
>



view thread (7+ messages)

Message-ID: <4B799ABE.9040701@gmail.com>
Permalink:  ../4B799ABE.9040701@gmail.com/
Also on:    postgresql.org/message-id/4B799ABE.9040701@gmail.com

 · 

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-sql@postgresql.org
  Cc: robjsargent@gmail.com
  Subject: Re: Can i force deletion of dependent rows?
  In-Reply-To: <4B799ABE.9040701@gmail.com>

* 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