二进制数据类型
MySQL数据库 |
GaussDB数据库 |
差异 |
---|---|---|
BINARY[(M)] |
支持,存在差异 |
|
VARBINARY(M) |
支持,存在差异 |
|
TINYBLOB |
支持,存在差异 |
|
BLOB |
支持,存在差异 |
|
MEDIUMBLOB |
支持,存在差异 |
|
LONGBLOB |
支持,存在差异 |
|
BIT[(M)] |
支持,存在差异 |
输出格式:
|
示例:
-- GaussDB场景 m_db=# CREATE TABLE test(a BINARY(10)) DISTRIBUTE BY REPLICATION; CREATE TABLE m_db=# INSERT INTO test VALUES(0x8000); INSERT 0 1 m_db=# SELECT hex(a) FROM test; hex ---------------------- 80202020202020202020 (1 row) m_db=# SELECT * FROM test WHERE hex(a) = 80000000000000000000; a --- (0 rows) m_db=# CREATE TABLE test2(a BINARY(10)) DISTRIBUTE BY REPLICATION; CREATE TABLE m_db=# INSERT INTO test2 VALUES(0x80008000); INSERT 0 1 m_db=# SELECT hex(a) FROM test2; hex ---------------------- 80202020202020202020 (1 row) m_db=# DROP TABLE test; DROP TABLE m_db=# DROP TABLE test2; DROP TABLE -- Mysql场景 mysql> CREATE TABLE test(a BINARY(10)); Query OK, 0 rows affected (0.01 sec) mysql> INSERT INTO test VALUES(0x8000); Query OK, 1 row affected (0.00 sec) mysql> SELECT hex(a) FROM test; +----------------------+ | hex(a) | +----------------------+ | 80000000000000000000 | +----------------------+ 1 row in set (0.00 sec) mysql> SELECT * FROM test WHERE hex(a) = 80000000000000000000; +------------+ | a | +------------+ | ▒ | +------------+ 1 row in set (0.00 sec) mysql> CREATE TABLE test2(a binary(10)); Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO test2 VALUES(0x80008000); Query OK, 1 row affected (0.00 sec) mysql> SELECT hex(a) FROM test2; +----------------------+ | hex(a) | +----------------------+ | 80008000000000000000 | +----------------------+ 1 row in set (0.00 sec) mysql> DROP TABLE test; Query OK, 0 rows affected (0.00 sec) mysql> DROP TABLE test2; Query OK, 0 rows affected (0.00 sec)