时间:2021-07-01 10:21:17 帮助过:13人阅读
http://blog.chinaunix.net/u/29134/showart_355336.html MYSQL 在默认的情况下查询是不区分 大小写 的,例如: mysql create table t1( - name varchar(10)); Query OK, 0 rows affected (0.09 sec) mysql insert into t1 values('you'),('You'),('YOU'); Q
http://blog.chinaunix.net/u/29134/showart_355336.html
MYSQL在默认的情况下查询是不区分大小写的,例如:
mysql> create table t1(
-> name varchar(10));
Query OK, 0 rows affected (0.09 sec)
mysql> insert into t1 values('you'),('You'),('YOU');
Query OK, 3 rows affected (0.05 sec)
Records: 3 Duplicates: 0 Warnings: 0
对这个表,缺省情况下,下面两个查询的结果是一样的:
如果想让MYSQL知道你输入的字母是大写还是小写的,修改表:
mysql> alter table t1 change name name varchar(10) binary;
Query OK, 3 rows affected (0.20 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select * from t1 where name = 'you';
+------+
| name |
+------+
| you |
+------+
1 row in set (0.00 sec)
mysql> select * from t1 where name = 'YOU';
+------+
| name |
+------+
| YOU |
+------+
1 row in set (0.00 sec)