将utf8_general_ci表和字段转换为utf8_unicode_ci [英] Converting utf8_general_ci tables and fields to utf8_unicode_ci

查看:1939
本文介绍了将utf8_general_ci表和字段转换为utf8_unicode_ci的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在几年前设计应用程序数据库时犯了一个错误,我的表和表字段的排序规则设置混合。其中一些是utf8_general_ci,其中一些是utf8_unicode_ci。

I have made a mistake when designing my application database several years ago and collation settings of my tables and table fields are mixed. Some of them are utf8_general_ci and some of them are utf8_unicode_ci.

当连接具有不同排序规则的表时会导致问题。现在,我打算更改排序规则设置,并使它们相同:utf8_unicode_ci。我将在所有的表上运行这两个SQL查询。

This causes problems when joining tables with different collations. Now, I am planning to change collation settings and make them the same: utf8_unicode_ci. I will be running these two SQL queries on all my tables.

ALTER TABLE  `table1` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE  `table1` CHANGE  `Action`  `Action` VARCHAR( 250 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;

我的问题是,运行这两个SQL查询会破坏任何字段值,特别是包含重音字符?还是可以安全地运行这两个查询?

My question is, does running these two SQL queries break any field values, especially the ones which contains accented characters? Or is it safe to run these two queries?

期待您的回音。

感谢您的回答!

推荐答案

请参考mysql doc which谈论改变字符集和排序规则

please refer mysql doc which talks about changing character set and collation

http://dev.mysql.com/doc/refman/5.1/en/charset-column.html

它的说法是如果您使用ALTER TABLE将列从一个字符集转换为另一个字符集,MySQL尝试映射数据值,但如果字符集不兼容,可能会有数据丢失。

Its saying that - "If you use ALTER TABLE to convert a column from one character set to another, MySQL attempts to map the data values, but if the character sets are incompatible, there may be data loss."

- 干杯

这篇关于将utf8_general_ci表和字段转换为utf8_unicode_ci的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆