当前的环境为
[list]
[*]OS: MS Windows7
[*]DB: 5.1.50-community MySQL Community Server (GPL)
[*]DB charset: utf8
[/list]
在MySql控制台输入show collation like 'utf8%';
找出MySql支持的 collation
其中,
utf8_general_ci 是大小写不敏感的
utf8_bin 是大小写敏感的
如下语句可查看出,哪一种方式是默认的。
[code]
mysql> show character set like '%utf8';
+---------+---------------+-------------------+--------+
| Charset | Description | Default collation | Maxlen |
+---------+---------------+-------------------+--------+
| utf8 | UTF-8 Unicode | utf8_general_ci | 3 |
+---------+---------------+-------------------+--------+
[/code]
在不更改数据默认设置的条件下,可在查询语句中指定。
这样就可以使用大小写敏感的查询了。
使用iBatis或JdbcTemplate情况下,这样的方式可以发挥较好的效果。
在使用hibernate时,如何操作,目前未知。
[list]
[*]OS: MS Windows7
[*]DB: 5.1.50-community MySQL Community Server (GPL)
[*]DB charset: utf8
[/list]
在MySql控制台输入show collation like 'utf8%';
找出MySql支持的 collation
其中,
utf8_general_ci 是大小写不敏感的
utf8_bin 是大小写敏感的
如下语句可查看出,哪一种方式是默认的。
[code]
mysql> show character set like '%utf8';
+---------+---------------+-------------------+--------+
| Charset | Description | Default collation | Maxlen |
+---------+---------------+-------------------+--------+
| utf8 | UTF-8 Unicode | utf8_general_ci | 3 |
+---------+---------------+-------------------+--------+
[/code]
在不更改数据默认设置的条件下,可在查询语句中指定。
select * from t_emp where _name like '%Ying%' collate utf_8;
这样就可以使用大小写敏感的查询了。
使用iBatis或JdbcTemplate情况下,这样的方式可以发挥较好的效果。
在使用hibernate时,如何操作,目前未知。