更改列排序规则 - 安全吗?
我的票务系统中有一个表,其中包含 15,000 条记录,每条记录都包含一封电子邮件,该电子邮件已转换为要添加到票证中的消息。
我们当前的问题是排序规则 - 当我接触系统时它使用的是 latin1_swedish_ci。然而,我们在系统中使用多种欧洲语言,因此我们需要能够正确存储非 ASCII 字符。
我无法让它与 latin1_swedish_ci 排序规则一起使用,但我在系统的测试版本中发现将排序规则切换为 utf8_bin 可以解决问题。
因此,我需要知道对实时系统上的表/列进行此更改是否安全。这会花费很长的时间(当你试图让它真正努力工作时,PHPMyAdmin 非常可怕)还是会损坏任何现有数据?
I have a table in my ticketing system with 15,000 records, each containing an email which has been converted into a message to be added to a ticket.
Our current problem is with collation - when I got my hands on the system it was using latin1_swedish_ci. However we use several European languages in the system and for that reason we need to be able to correctly store non-ASCII characters.
I was unable to get this to work with the latin1_swedish_ci collation but I have found on my test version of the system that switching the collation to utf8_bin solves the problem.
So I need to know if it will be safe to make this change to my table/column on the live system. Will this take a long amount of time (PHPMyAdmin is pretty horrible when you try to make it work really hard) or will it corrupt any existing data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当第一个字符集中的所有字符都可以在第二个字符集中表示时,从一个字符集转换为另一个字符集是安全的。
latin1 转 utf8 就是这样:它是安全的。
但是您必须确保应用程序本身可以处理 utf8 数据。
在 utf8_bin 上:utf8 部分是字符集(字符的编码方式),bin 部分是排序规则。不要使用 bin,它会使所有内容区分大小写,这可能不是您所期望的。尝试使用 utf8_unicode_ci 代替。 (参见http://dev.mysql.com/doc /refman/5.5/en/charset-unicode-sets.html )
It's safe to convert from one charset to an other when all characters from the first charset are representable in the second charset.
This is the case for latin1 to utf8: it's safe.
However you have to ensure that the application itself can handle utf8 data.
On utf8_bin: The utf8 part is the charset (how characters are encoded) and the bin part is the collation. Don't use bin, it would make everything case-sensitive, which is probably not what you expect. Try utf8_unicode_ci instead. (See http://dev.mysql.com/doc/refman/5.5/en/charset-unicode-sets.html )