Re: CASCADING update
От | Obe, Regina |
---|---|
Тема | Re: CASCADING update |
Дата | |
Msg-id | 53F9CF533E1AA14EA1F8C5C08ABC08D204D18979@ZDND.DND.boston.cob обсуждение исходный текст |
Ответ на | CASCADING update ("A B" <gentosaker@gmail.com>) |
Список | pgsql-novice |
Be careful. Since it appears you have delete cascade, when you delete user 2, then all children in the other tables for 2 will be deleted as well. I tend to put in delete restrict to prevent accidentally deleting a lot of important data. As far as what you are trying to do, unfortunately I don't think there is an easy way to do this without explicitly updating each table. Would like to know if there is though. Thanks, Regina -----Original Message----- From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of A B Sent: Friday, October 03, 2008 5:48 AM To: pgsql-novice@postgresql.org Subject: [NOVICE] CASCADING update 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? -- Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-novice ----------------------------------------- The substance of this message, including any attachments, may be confidential, legally privileged and/or exempt from disclosure pursuant to Massachusetts law. It is intended solely for the addressee. If you received this in error, please contact the sender and delete the material from any computer.
В списке pgsql-novice по дате отправления: