BINARY(n) ,varBINARY(n): N代表字节数
utf8: mysql> CREATE TABLE t (c BINARY(3)); Query OK, 0 rows affected (0.04 sec) mysql> INSERT INTO t SET c = ‘a‘; Query OK, 1 row affected (0.19 sec) mysql> SELECT HEX(c), c = ‘a‘, c = ‘a\0\0‘ from t; +--------+---------+-------------+ | HEX(c) | c = ‘a‘ | c = ‘a\0\0‘ | +--------+---------+-------------+ | 610000 | 0 | 1 | +--------+---------+-------------+ 1 row in set (0.01 sec) mysql> CREATE TABLE tr (c varBINARY(3)); Query OK, 0 rows affected (0.04 sec) mysql> INSERT INTO tr SET c = ‘a‘; Query OK, 1 row affected (0.00 sec) mysql> SELECT HEX(c), c = ‘a‘, c = ‘a\0\0‘ from tr; +--------+---------+-------------+ | HEX(c) | c = ‘a‘ | c = ‘a\0\0‘ | +--------+---------+-------------+ | 61 | 1 | 0 | +--------+---------+-------------+ 1 row in set (0.01 sec)
时间: 2024-10-17 23:30:24