H2 内存数据库在 MySQL 模式下以不同方式对待 ORDER BY

发布于 2024-11-18 09:15:37 字数 161 浏览 12 评论 0原文

我有一个查询,它对包含电子邮件地址的 VARCHAR 列执行ORDER BY

如果我访问物理 MySQL 数据库,它会忽略 ORDER BY 中的大小写。但是,我的 h2 内存数据库尊重大小写。它被设置为 MySQL 模式。

有谁知道这是为什么吗?

I have a query that does anORDER BY on a VARCHAR column that contains email addresses.

If I hit my physical MySQL db, it ignores case in the ORDER BY. However, my h2 in-memory DB is respecting case. It is set to MySQL mode.

Anyone know why this is?

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

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

发布评论

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

评论(3

半世蒼涼 2024-11-25 09:15:38

评估数据库中的字符串时区分大小写是由排序规则决定的。

检查 H2 上的排序规则处理: http://www.h2database.com/html/grammar .html#set_collat​​ion

Case sensitivity when evaluating strings in databases is determined by the collation.

Check the collation handling on H2: http://www.h2database.com/html/grammar.html#set_collation

糖果控 2024-11-25 09:15:38

作为使用排序规则的替代方法,您可以使用 SET IGNORECASE TRUE 禁用区分大小写。这需要在创建表之前完成。

H2 的 MySQL 模式不区分大小写的原因是:H2 中的兼容模式不会影响事物的持久化方式(否则稍后您将无法以不同的兼容模式访问数据库) ,或禁用兼容模式)。区分大小写确实会影响事物的存储方式(特别是索引)。

As an alternative to using a collation, you can disable case sensitivity using SET IGNORECASE TRUE. This needs to be done before creating the tables.

The reason why the MySQL mode of H2 isn't case insensitive is: compatibility modes in H2 don't affect how things are persisted (otherwise you couldn't access a database in a different compatibility mode later on, or disable the compatibility mode). Case sensitivity does affect how things are stored (specially indexes).

自此以后,行同陌路 2024-11-25 09:15:38

使用 VARCHAR_IGNORECASE 而不是 VARCHAR

参考

Use VARCHAR_IGNORECASE instead of VARCHAR.

Reference

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