MariaDB / MySQL 查询是否区分大小写?
MariaDB / MySQL querys are case sensitive?
我只想知道查询是否区分大小写。这些查询是否相同?
SELECT * FROM Users WHERE login="john";
SELECT * FROM Users WHERE login="John";
SELECT * FROM Users WHERE login="JOHN";
SELECT * FROM Users WHERE login="jOHn";
我已经在我的控制台上试过了,它们都有效,但如果我要使用 Hibernate 或其他任何东西,我想确定这一点。
谢谢!
The default character set and collation are latin1 and
latin1_swedish_ci, so nonbinary string comparisons are case
insensitive by default
关于你问题的第二部分 - this SO answer 向你展示了如何配置搜索者区分大小写。
来自MariaDB docs,取决于OS。对于 Windows,它不是 case-sensitive。对于 Linux、数据库、table、table 别名和触发器名称受系统影响 case-sensitivity,而索引、列、列别名、存储例程和事件名称永远不会区分大小写。
只是我的 Linux ( Debian 10 ) Box in MariaDB (Ver.10.3.18-MariaDB-0+deb10u1 ) 中的一个例子。可能对某人有帮助!!
MariaDB [niffdb]> select * from account_heads where head_desc="Fuel";
+---------+-----------+
| head_id | head_desc |
+---------+-----------+
| 1 | Fuel |
+---------+-----------+
1 row in set (0.004 sec)
MariaDB [niffdb]> select * from account_heads where head_desc="FUEL";
+---------+-----------+
| head_id | head_desc |
+---------+-----------+
| 1 | Fuel |
+---------+-----------+
1 row in set (0.001 sec)
MariaDB [niffdb]> select * from account_heads where head_desc="fUEL";
+---------+-----------+
| head_id | head_desc |
+---------+-----------+
| 1 | Fuel |
+---------+-----------+
1 row in set (0.001 sec)
MariaDB [niffdb]>
我只想知道查询是否区分大小写。这些查询是否相同?
SELECT * FROM Users WHERE login="john";
SELECT * FROM Users WHERE login="John";
SELECT * FROM Users WHERE login="JOHN";
SELECT * FROM Users WHERE login="jOHn";
我已经在我的控制台上试过了,它们都有效,但如果我要使用 Hibernate 或其他任何东西,我想确定这一点。
谢谢!
The default character set and collation are latin1 and latin1_swedish_ci, so nonbinary string comparisons are case insensitive by default
关于你问题的第二部分 - this SO answer 向你展示了如何配置搜索者区分大小写。
来自MariaDB docs,取决于OS。对于 Windows,它不是 case-sensitive。对于 Linux、数据库、table、table 别名和触发器名称受系统影响 case-sensitivity,而索引、列、列别名、存储例程和事件名称永远不会区分大小写。
只是我的 Linux ( Debian 10 ) Box in MariaDB (Ver.10.3.18-MariaDB-0+deb10u1 ) 中的一个例子。可能对某人有帮助!!
MariaDB [niffdb]> select * from account_heads where head_desc="Fuel";
+---------+-----------+
| head_id | head_desc |
+---------+-----------+
| 1 | Fuel |
+---------+-----------+
1 row in set (0.004 sec)
MariaDB [niffdb]> select * from account_heads where head_desc="FUEL";
+---------+-----------+
| head_id | head_desc |
+---------+-----------+
| 1 | Fuel |
+---------+-----------+
1 row in set (0.001 sec)
MariaDB [niffdb]> select * from account_heads where head_desc="fUEL";
+---------+-----------+
| head_id | head_desc |
+---------+-----------+
| 1 | Fuel |
+---------+-----------+
1 row in set (0.001 sec)
MariaDB [niffdb]>