From: | Jonathan Bartlett <johnnyb(at)eskimo(dot)com> |
---|---|
To: | Dmitry Tkach <dmitry(at)openratings(dot)com> |
Cc: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: CREATE TABLE with REFERENCE |
Date: | 2003-07-29 20:07:11 |
Message-ID: | Pine.GSU.4.44.0307291259510.29931-100000@eskimo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | btober | 2003-07-29 20:19:46 | Does the block of code in a stored procedure execute as a transaction? |
Previous Message | Dmitry Tkach | 2003-07-29 19:58:50 | Re: Basic questions before start |