Re: CREATE TABLE with REFERENCE
От | Jonathan Bartlett |
---|---|
Тема | Re: CREATE TABLE with REFERENCE |
Дата | |
Msg-id | Pine.GSU.4.44.0307291259510.29931-100000@eskimo.com обсуждение исходный текст |
Ответ на | Re: CREATE TABLE with REFERENCE (Dmitry Tkach <dmitry@openratings.com>) |
Список | pgsql-general |
> begin; > set constraints all immediate; > update users set id=<new_userid> where login = 'customerA'; > set constraints all deferred; > delete from users where login = 'custmerA'; > update users set id=<new_userid> where login = 'custmerB'; > delete from users where login = 'customerB'; > insert into users values (<new_id>, 'merged_customer_login', ...); > commit; > > This should take care about rerouting all the depending entries to the > new user *as long as you have your FKs setup properly*, of course. Interesting. After reading this I went back to the docs and found what I haven't found before: "Analogous to ON DELETE there is also ON UPDATE which is invoked when a primary key is changed (updated). The possible actions are the same." I was under the impression that cascades only applied to deletes. Something new to chew on. Thanks! Jon
В списке pgsql-general по дате отправления: