How to update each id column (including foreign keys) so that it is its original time value of 10, then add 1 for the first database and 2 for the second database.
Thus, id 1 becomes 11 on db 1 and 12 on db 2. Since the primary and foreign keys go through the same change, you don’t have to worry about how the records relate, you just make updates using the same formula.
So it will be like
In db 1:
UPDATE user SET id = id * 10 + 1; UPDATE privilege SET id = id * 10 + 1, user_id = user_id * 10 + 1;
In db 2:
UPDATE user SET id = id * 10 + 2; UPDATE privilege SET id = id * 10 + 2, user_id = user_id * 10 + 2;
source share