[英]Database conversion from latin1 to utf8mb4, what about indexes?
I noticed that my MODX database still uses latin1 character set in the database and in its tables.我注意到我的 MODX 数据库在数据库及其表中仍然使用 latin1 字符集。 I would like to convert them to utf8mb4 and update collations accordingly.我想将它们转换为 utf8mb4 并相应地更新排序规则。
Not totally sure how I should do this.不完全确定我应该如何做到这一点。 Is this correct?这样对吗?
Are indexes updated automatically?索引会自动更新吗? Is there something else I should be aware of?还有什么我应该注意的吗?
A bonus question: what would be the most suitable latest utf8_unicode collation?一个额外的问题:最合适的最新 utf8_unicode 排序规则是什么? Western languages should work.西方语言应该有效。
Changing the default character sets of a table or a schema does not change the data in the column itself, it only changes the default to apply the next time you add a table or add a column to a table.更改表或架构的默认字符集不会更改列本身中的数据,只会更改下一次添加表或向表中添加列时应用的默认值。
To convert current data, alter one table at a time:要转换当前数据,请一次更改一张表:
ALTER TABLE <name> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
The collation utf8mb4_0900_ai_ci is faster than earlier collations (at least according to the documentation ), and it's the most current and accurate.归类 utf8mb4_0900_ai_ci 比早期的归类更快(至少根据文档),并且它是最新和最准确的。 This collation requires MySQL 8.0.此排序规则需要 MySQL 8.0。
The most current collation in MySQL 5.7 is utf8_unicode_520_ci. MySQL 5.7 中最新的排序规则是 utf8_unicode_520_ci。
A table-conversion like this rebuilds the indexes, so there's nothing else you need to do.像这样的表转换会重建索引,因此您无需执行任何其他操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.