码迷,mamicode.com
首页 > 其他好文 > 详细

The BINARY and VARBINARY Types

时间:2016-06-19 16:49:04      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

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 x4D7953514C;
+---------------+
| x4D7953514C |
+---------------+
| MySQL         |
+---------------+
1 row in set (0.00 sec)

mysql> select x612000;
+-----------+
| x612000 |
+-----------+
| a         |
+-----------+
1 row in set (0.00 sec)

mysql> select x610000;
+-----------+
| x610000 |
+-----------+
| 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

标签:

原文地址:http://www.cnblogs.com/zengkefu/p/5598169.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!