The BINARY and VARBINARY Types
Posted zengkefu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了The BINARY and VARBINARY Types相关的知识,希望对你有一定的参考价值。
mysql> CREATE TABLE t (c BINARY(3)); Query OK, 0 rows affected (0.21 sec) mysql> INSERT INTO t SET c = ‘a‘; Query OK, 1 row affected (0.18 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.00 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 | | 610000 | 0 | 1 | +--------+---------+-------------+ 2 rows in set (0.00 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 | | 610000 | 0 | 1 | | 612000 | 0 | 0 | +--------+---------+-------------+ 3 rows in set (0.00 sec) mysql> SELECT x‘4D7953514C‘; +---------------+ | x‘4D7953514C‘ | +---------------+ | MySQL | +---------------+ 1 row in set (0.00 sec) mysql> select x‘612000‘; +-----------+ | x‘612000‘ | +-----------+ | a | +-----------+ 1 row in set (0.00 sec) mysql> select x‘610000‘; +-----------+ | x‘610000‘ | +-----------+ | a | +-----------+ 1 row in set (0.00 sec)
mysql> CREATE TABLE t2 (c varBINARY(3)); Query OK, 0 rows affected (0.23 sec) mysql> INSERT INTO t2 SET c = ‘a‘; Query OK, 1 row affected (0.17 sec) mysql> select * from t2; +------+ | c | +------+ | a | +------+ 1 row in set (0.00 sec) mysql> SELECT HEX(c), c = ‘a‘, c = ‘a\0\0‘ from t2; +--------+---------+-------------+ | HEX(c) | c = ‘a‘ | c = ‘a\0\0‘ | +--------+---------+-------------+ | 61 | 1 | 0 | +--------+---------+-------------+ 1 row in set (0.00 sec)
以上是关于The BINARY and VARBINARY Types的主要内容,如果未能解决你的问题,请参考以下文章
BigQuery 中 MySQL 的 binary(8) 和 varbinary(16) 的等价物是啥?
CF.862D.Mahmoud and Ehab and the binary string(交互 二分)
Codeforces 862D. Mahmoud and Ehab and the binary string (二分)
D. Mahmoud and Ehab and the binary string Codeforces Round #435 (Div. 2)