更新时间:2025-09-09 GMT+08:00
数据类型支持的属性
|
MySQL数据库 |
GaussDB数据库 |
|---|---|
|
NULL |
支持 |
|
NOT NULL |
支持 |
|
DEFAULT |
支持 |
|
ON UPDATE |
支持 |
|
PRIMARY KEY |
支持 |
|
AUTO_INCREMENT |
支持 |
|
CHARACTER SET name |
支持 |
|
COLLATE name |
支持 |
|
ZEROFILL |
支持 |
使用CREATE TABLE AS方式建表,对VARBINARY类型的字段设置默认值,在使用SHOW CREATE TABLE、DESC或\d 查询的时候回显与MySQL存在差异,GaussDB显示为转换成十六进制后的值,而MySQL显示为原值。
示例:
m_db=# CREATE TABLE test_int(
int_col INT
);
m_db=# CREATE TABLE test_varbinary(
varbinary_col VARBINARY(20) default 'gauss'
) AS SELECT * FROM test_int;
m_db=# SHOW CREATE TABLE test_varbinary;
Table | Create Table
----------------+---------------------------------------------------------------------------
test_varbinary | SET search_path = public; +
| CREATE TABLE test_varbinary ( +
| varbinary_col varbinary(20) DEFAULT X'6761757373', +
| int_col integer +
| ) +
| CHARACTER SET = "UTF8" COLLATE = "utf8mb4_general_ci" +
| WITH (orientation=row, compression=no, storage_type=USTORE, segment=off);
(1 row)
m_db=# DROP TABLE test_int, test_varbinary;
mysql> CREATE TABLE test_int(
int_col INT
);
mysql> CREATE TABLE test_varbinary(
varbinary_col VARBINARY(20) default 'gauss'
) AS SELECT * FROM test_int;
mysql> SHOW CREATE TABLE test_varbinary;
+----------------+--------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+----------------+--------------------------------------------------------------------------------------------------------------------+
| test_varbinary | CREATE TABLE `test_varbinary` (
`varbinary_col` varbinary(20) DEFAULT 'gauss',
`int_vol` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+----------------+--------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> DROP TABLE test_int, test_varbinary;
父主题: 数据类型