Can i force deletion of dependent rows?

From: Shruthi A <shruthi(dot)iisc(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Can i force deletion of dependent rows?
Date: 2010-02-13 06:11:14
Message-ID: 6caee9521002122211q7e4fd2fcj1a0489fd64dc204a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,

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.

Thanks,
Shruthi

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tim Landscheidt 2010-02-13 07:05:59 Re: Can i force deletion of dependent rows?
Previous Message Tim Landscheidt 2010-02-12 23:55:38 Re: complex join question