Updated on 2024-12-06 GMT+08:00

Attributes Supported by Data Types

Table 1 Attributes supported by data types

No.

MySQL

GaussDB

1

NULL

Supported.

2

NOT NULL

Supported.

3

DEFAULT

Supported.

4

ON UPDATE

Supported.

5

PRIMARY KEY

Supported.

6

AUTO_INCREMENT

Supported.

7

CHARACTER SET name

Supported.

8

COLLATE name

Supported.

9

ZEROFILL

Supported.

When CREATE TABLE AS is used to create a table and default values are set for fields of the VARBINARY type, the command output of SHOW CREATE TABLE, DESC, or \d is different from that of MySQL. The value displayed in GaussDB is a hexadecimal value, but MySQL displays the original value.

Example:
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;