mysql字符集utf 8排序规则(dup键)不能正常工作 [英] mysql character set utf 8 collation (dup key) not working properly

查看:130
本文介绍了mysql字符集utf 8排序规则(dup键)不能正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库表字符集和排序规则分别设置为 utf-8 utf8_general_ci 。我在varchar列中插入了值为'säîkîråñ'的记录。我有一个唯一的列约束。当我尝试插入'sai kiran',它提供重复的条目,参考旧的插入行'säîkîråñ'。

My database tables character-set and collation set to utf-8 and utf8_general_ci respectively. I inserted a record with value 'säî kîråñ' in varchar column. I have a unique column constraint on that. When I try to insert 'sai kiran' its giving duplicate entry referring to old inserted row of 'säî kîråñ'.

正如你可以看到,在两个字符串中的字符是完全不同的utf8字符集,不明白为什么它显示错误为重复条目。

As you can see the characters in both the strings are completely different in utf8 character-set, couldn't understand why it is showing error as 'duplicate entry'.

我尝试将归类更改为 utf8_unicode_ci ,但没有用。我试过直接插入phpmyadmin避免prog lang编码问题,仍然有问题依然存在。

I tried changing collation to utf8_unicode_ci but no use. I tried directly inserting in phpmyadmin to avoid prog lang encoding problems, still the problem persists.

推荐答案

utf8_general_ci 的情况下,我认为只有'a'和'A'将被视为相同,但从这里我发现即使'a'和'ä'因此 utf8_bin 是处理它们的最终解决方案。良好的学习。

In case of utf8_general_ci I thought only 'a' and 'A' would be treated same, but from here I found that even 'a' and 'ä' would be treated same. So utf8_bin is the ultimate solution to treat them different. Good learning though.

这篇关于mysql字符集utf 8排序规则(dup键)不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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