CASCADING update

From: "A B" <gentosaker(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: CASCADING update
Date: 2008-10-03 09:47:49
Message-ID: dbbf25900810030247l450e1ae7uc40276e1fda63402@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have a base table User (id serial primary key, name text);
and a lot of tables like this
Foo (id integer references User on update cascade on delete cascade, ....);

Assume I have
id =1 name= aaa
id =2 name= bbb

in the user table

and now I wish to remove the user with id=2, but I also want to
update all the Foo tables and set the id to 1 (the other user takes
over all the items), but I do not want to do this by calling update
for each table separatly.
The "on update cascade" sounds like what I need, in some way, but I'm
not sure how to really use it in this case.
Is it possible? If yes, how?

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Steve T 2008-10-03 09:59:00 Re: Forcing order of Joins etc
Previous Message Steve T 2008-10-03 09:01:45 Forcing order of Joins etc