MySQL 中的排序规则

发布于 2024-11-05 03:23:40 字数 325 浏览 3 评论 0原文

Collat​​e Latin1_General_CS_AS 和 Collat​​e utf8_bin 是否相同,它们是不同的,前者用于 Latin1 字符集,后者用于 utf8 字符集,但我想知道两者是否都会进行区分大小写和重音敏感的匹配。

实际上,现在我已经将数据库从 sql server2000 迁移到 MySQL 5.2,我有一个密码字段,我想与 sql server 中的区分大小写和重音敏感的字段进行比较,Collat​​e Latin1_General_CS_AS 工作正常,但我想知道 Collat​​e utf8_bin 是替代品对于 MySQL 来说,或者还有其他一些更好的方法可以实现相同的目的。

Whether Collate Latin1_General_CS_AS and Collate utf8_bin are same, well they are different the former is for Latin1 charset and the latter is for utf8 charset but i wanted to know whether both of will do case sensitive and Accent sensitive match.

Actually just now i have migrated my database from sql server2000 to MySQL 5.2 and i have a password field which i want to compare with case sensitive and Accent sensitive in sql server that Collate Latin1_General_CS_AS is working fine but i want to know Collate utf8_bin is the replacement for that in MySQL or there are some other better ways to achieve the same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等风来 2024-11-12 03:23:40

我不知道 SQL Server 和你提到的排序规则,但是 utf8_bin 是一个 二进制排序规则,确实区分大小写和重音。

不过,您不一定需要在该排序规则中包含整个数据库 - 二进制排序规则在 排序。您可以使用 COLLATE 关键字

SELECT column FROM table WHERE password COLLATE utf8_bin = "abcäöü"; 

I don't know SQL server and the collation you mention, but utf8_bin, being a binary collation, is indeed case and accent sensitive.

You don't necessarily need to have the entire database in that collation though - binary collations are not great at sorting. You can force a binary comparison in a non-binary collation (like utf8_general_ci) using the COLLATE keyword:

SELECT column FROM table WHERE password COLLATE utf8_bin = "abcäöü"; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文