Plan to use a PHP script to complete the function, the current data backup, filtering and player ID update has been completed, that is, when the data import, some tables of the primary key is the self-increment ID, there is no thought of a particularly good plan. Please give me some expert advice, how can be a good compatibility to solve this problem?
Reply content:
Plan to use a PHP script to complete the function, the current data backup, filtering and player ID update has been completed, that is, when the data import, some tables of the primary key is the self-increment ID, there is no thought of a particularly good plan. Please give me some expert advice, how can be a good compatibility to solve this problem?
Since rendezvous once, meet the second time, it is recommended to change into a UUID directly in place, convenient for later to fit
First write a [table, ID, server]=>[uuid] conversion, and then the original table all follow the UUID re-write again, and then let the production environment originally wrote a copy of the two copies (old table and UUID new table), and then slowly read to switch to the new table, The last old table can be lost only if it is written and not read. At this point, no matter how the uniform is silky smooth, no risk.
Once helped the big brother of the curtain, met the same problem. Our solution is to write a small program to select out first, then insert in.
The maximum self-increment ID of a suit is 100, which adds 100 to all the self-increment IDs of B-suits.
I have not practiced, where I have seen such a scheme before, visual inspection is feasible, the actual situation is not very clear.
For informational purposes only.
The simplest scenario is to prefix the large region ID.
Or, with the ID of the physical server as the prefix, the ID of each database must be different.
Another option is to break the player data from different servers into different tables (albeit in a database) based on the server's table, but the data will not conflict, although it is cumbersome to manage.
Do not use the self-increment numeric ID as the primary key, use the UUID directly as the primary key. Whether you are in a uniform or distributed, it is the simplest way.