The BINARY and VARBINARY Types

mysql> CREATE TABLE t (c BINARY());
Query OK, rows affected (0.21 sec) mysql> INSERT INTO t SET c = 'a';
Query OK, 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' |
+--------+---------+-------------+
| | | |
+--------+---------+-------------+
row in set (0.00 sec) mysql> INSERT INTO t SET c = 'a';
Query OK, 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' |
+--------+---------+-------------+
| | | |
| | | |
+--------+---------+-------------+
rows in set (0.00 sec) mysql> INSERT INTO t SET c = 'a ';
Query OK, 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' |
+--------+---------+-------------+
| | | |
| | | |
| | | |
+--------+---------+-------------+
rows in set (0.00 sec) mysql> SELECT x'4D7953514C';
+---------------+
| x'4D7953514C' |
+---------------+
| MySQL |
+---------------+
row in set (0.00 sec) mysql> select x'';
+-----------+
| x'' |
+-----------+
| a |
+-----------+
row in set (0.00 sec) mysql> select x'';
+-----------+
| x'' |
+-----------+
| a |
+-----------+
row in set (0.00 sec)
mysql> CREATE TABLE t2 (c varBINARY());
Query OK, rows affected (0.23 sec) mysql> INSERT INTO t2 SET c = 'a';
Query OK, row affected (0.17 sec) mysql> select * from t2;
+------+
| c |
+------+
| a |
+------+
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' |
+--------+---------+-------------+
| | | |
+--------+---------+-------------+
row in set (0.00 sec)
上一篇:Razor视图引擎布局 Razor视图引擎的基本概念与法语 SQL Server Mobile 和 .NET 数据访问接口之间的数据类型映射 binary 和 varbinary datetime 和 smalldatetime float 和 real


下一篇:最常用的截取函数有left,right,substring