Skip site navigation (1) Skip section navigation (2)


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: (view raw, whole thread or download thread mbox)
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?


pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group