· 10 years ago · Sep 09, 2016, 10:08 PM
1AUTH:
2
3A.1. You must create a new account ID reorder table, and assign new id's to old id's. Here the SQL for do it:
4
5DROP TABLE IF EXISTS `reorder_account_id`;
6CREATE TABLE `reorder_account_id` (
7 `new_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Global Unique Identifier',
8 `old_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier',
9 PRIMARY KEY (`new_id`)
10) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
11
12INSERT INTO reorder_account_id (old_id) SELECT account.id FROM account;
13
14
15A.2. Now you must reorder all id's with tables that use account id's. An example SQL for do it with "account" table:
16
17UPDATE account JOIN reorder_account_id ON account.id = reorder_account_id.old_id SET account.id = reorder_account_id.new_id;
18
19Very important: Is needed that you delete all PRIMARY KEYS (only tables that have) before reorder, and after reordered you add it again
20Is HIGHLY RECOMMENDED that create INDEX on each table that not have for improve speed of the reorder.
21
22A.3. After do all, all id's and id's be reordered.
23
24
25
26CHARACTERS:
27
28B.1. You must create a new characters GUID reorder table, and assign new guid's to old guid's. Here the SQL for do it:
29
30DROP TABLE IF EXISTS `reorder_characters_guid`;
31CREATE TABLE `reorder_characters_guid` (
32 `new_guid` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Global Unique Identifier',
33 `old_guid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier',
34 PRIMARY KEY (`new_guid`)
35) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
36
37INSERT INTO reorder_characters_guid (old_guid) SELECT characters.guid FROM characters;
38
39
40B.2. Now you must reorder all guid's with tables that use characters guid's. An example SQL for do it with "characters" table:
41
42UPDATE characters JOIN reorder_characters_guid ON characters.guid = reorder_characters_guid.old_guid SET characters.guid = reorder_characters_guid.new_guid;
43
44Very important: Is needed that you delete all PRIMARY KEYS (only tables that have) before reorder, and after reordered you add it again
45Is HIGHLY RECOMMENDED that create INDEX on each table that not have for improve speed of the reorder.
46
47B.3. After do all, all id's and guid's be reordered.
48
49
50
51C.1. Also GUILDS, MAIL and ITEMS must be reordered.
52
53DROP TABLE IF EXISTS `reorder_items_guid`;
54CREATE TABLE `reorder_items_guid` (
55 `new_guid` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Global Unique Identifier',
56 `old_guid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier',
57 PRIMARY KEY (`new_guid`)
58) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
59
60INSERT INTO reorder_items_guid (old_guid) SELECT item_instance.guid FROM item_instance;
61
62DROP TABLE IF EXISTS `reorder_guild_id`;
63CREATE TABLE `reorder_guild_id` (
64 `new_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Global Unique Identifier',
65 `old_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier',
66 PRIMARY KEY (`new_id`)
67) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
68
69INSERT INTO reorder_guild_id (old_guid) SELECT guild.guildid FROM guild;
70
71DROP TABLE IF EXISTS `reorder_mail_id`;
72CREATE TABLE `reorder_mail_id` (
73 `new_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Global Unique Identifier',
74 `old_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier',
75 PRIMARY KEY (`new_id`)
76) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
77
78INSERT INTO reorder_mail_id (old_guid) SELECT mail.id FROM mail;
79
80
81C.2. After AUTH, CHARACTERS, GUILD, ITEM and MAIL reordered, must repeat all steps with the other db, but with the next id after the last id of each table.
82
83For example, after database A have account ID's reordered, and there are a 120.000 accounts, the last ID will be 120.000, so the next account ID for account database reorder for database B, must be 120.001.
84
85You must create the new account id reorder database with these value on auto_increment.
86
87DROP TABLE IF EXISTS `reorder_account_id`;
88CREATE TABLE `reorder_account_id` (
89 `new_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Global Unique Identifier',
90 `old_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier',
91 PRIMARY KEY (`new_id`)
92) ENGINE=InnoDB AUTO_INCREMENT=120.001 DEFAULT CHARSET=utf8;
93
94And repeat the proccess with the same things.