mysql字符集校验,请教个字符集校验的问题

root:[localhost][test]> show global variables like '%char%';

+--------------------------+----------------------------+

| Variable_name            | Value                      |

+--------------------------+----------------------------+

| character_set_client     | utf8                       |

| character_set_connection | utf8                       |

| character_set_database   | utf8                       |

| character_set_filesystem | binary                     |

| character_set_results    | utf8                       |

| character_set_server     | utf8                       |

| character_set_system     | utf8                       |

| character_sets_dir       | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

8 rows in set (0.00 sec)

root:[localhost][test]> show global variables like '%coll%';

+----------------------+----------+

| Variable_name        | Value    |

+----------------------+----------+

| collation_connection | utf8_bin |

| collation_database   | utf8_bin |

| collation_server     | utf8_bin |

+----------------------+----------+

3 rows in set (0.00 sec)

root:[localhost][test]>

root:[localhost][test]>

root:[localhost][test]>

root:[localhost][test]> show variables like '%char%';

+--------------------------+----------------------------+

| Variable_name            | Value                      |

+--------------------------+----------------------------+

| character_set_client     | utf8                       |

| character_set_connection | utf8                       |

| character_set_database   | utf8                       |

| character_set_filesystem | binary                     |

| character_set_results    | utf8                       |

| character_set_server     | utf8                       |

| character_set_system     | utf8                       |

| character_sets_dir       | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

8 rows in set (0.00 sec)

root:[localhost][test]> show variables like '%coll%';

+----------------------+-----------------+

| Variable_name        | Value           |

+----------------------+-----------------+

| collation_connection | utf8_general_ci |

| collation_database   | utf8_general_ci |

| collation_server     | utf8_bin        |

+----------------------+-----------------+

3 rows in set (0.00 sec)

root:[localhost][test]> set collation_connection=utf8_bin;

Query OK, 0 rows affected (0.00 sec)

root:[localhost][test]> set collation_database=utf8_bin;

Query OK, 0 rows affected (0.00 sec)

root:[localhost][test]> show variables like '%coll%';

+----------------------+----------+

| Variable_name        | Value    |

+----------------------+----------+

| collation_connection | utf8_bin |

| collation_database   | utf8_bin |

| collation_server     | utf8_bin |

+----------------------+----------+

3 rows in set (0.00 sec)

root:[localhost][test]>

root:[localhost][test]> create table t1 (c1 int, c2 varchar(10) character set utf8 collate utf8_bin) default charset=utf8 collate=utf8_bin;

Query OK, 0 rows affected (0.10 sec)

root:[localhost][test]>

root:[localhost][test]>

root:[localhost][test]> show create table t1\G

*************************** 1. row ***************************

Table: t1

Create Table: CREATE TABLE `t1` (

`c1` int(11) DEFAULT NULL,

`c2` varchar(10) COLLATE utf8_bin DEFAULT NULL

) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin

1 row in set (0.00 sec)

root:[localhost][test]>

root:[localhost][test]>

root:[localhost][test]> insert into t1 values(1,'a'),(2,'A');

Query OK, 2 rows affected (0.00 sec)

Records: 2  Duplicates: 0  Warnings: 0

root:[localhost][test]> select * from t1;

+------+------+

| c1   | c2   |

+------+------+

|    1 | a    |

|    2 | A    |

+------+------+

2 rows in set (0.00 sec)

root:[localhost][test]> select * from t1 where c2='a';

+------+------+

| c1   | c2   |

+------+------+

|    1 | a    |

+------+------+

1 row in set (0.00 sec)

root:[localhost][test]> select * from t1 where c2='A';

+------+------+

| c1   | c2   |

+------+------+

|    2 | A    |

+------+------+

1 row in set (0.00 sec)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值