BINARY and varBINARY
Posted zengkefu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了BINARY and varBINARY相关的知识,希望对你有一定的参考价值。
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)
以上是关于BINARY and varBINARY的主要内容,如果未能解决你的问题,请参考以下文章
BigQuery 中 MySQL 的 binary(8) 和 varbinary(16) 的等价物是啥?