All Products
Search
Document Center

ApsaraDB for OceanBase:Change the type of a constrained column

Last Updated:Jun 03, 2024

This topic describes incompatibilities between MySQL databases and MySQL tenants of OceanBase Database when you change the type of a constrained column. The incompatibilities vary depending on the constraint.

Note

In the following tables, an empty cell in the type column indicates that the type is not supported by the corresponding constraint, a hyphen (-) means N/A, and 'All' means all types.

Change the type of a PRIMARY KEY column

The following table describes the types to which you can change a PRIMARY KEY column by executing the ALTER TABLE table_name MODIFY/CHANGE COLUMN DDL statement in a MySQL database and a MySQL tenant of OceanBase Database.

Column type in a MySQL database

Supported target type

Column type in a MySQL tenant of OceanBase Database

Supported target type

INT

All

INTEGER

-

TINYINT

All

TINYINT

BOOLEAN

SMALLINT

All

SMALLINT

-

MEDIUMINT

All

MEDIUMINT

-

BIGINT

All

BIGINT

-

BOOL

All

BOOLEAN

TINYINT

DECIMAL

All

DECIMAL

-

NUMERIC

All

NUMERIC

-

REAL

All

FLOAT

-

DOUBLE

All

DOUBLE

-

FLOAT

All

FLOAT

-

BIT

All

BIT

-

CHAR

All

CHAR

-

NCHAR

All

CHAR

-

VARCHAR

All

VARCHAR

-

BINARY

All

BINARY

-

VARBINARY

All

VARBINARY

-

LONG VARBINARY

All

YEAR

All

YEAR

-

DATE

All

DATE

-

TIME

All

TIME

-

TIMESTAMP

All

TIMESTAMP

-

DATETIME

All

DATETIME

-

TINYBLOB

All

MEDIUMBLOB

All

BLOB

All

LONGBLOB

All

TINYTEXT

All

MEDIUMTEXT

All

TEXT

All

LONGTEXT

All

ENUM

All

ENUM

-

SET

All

SET

-

JSON

All

Change the type of a UNIQUE KEY column

If a UNIQUE KEY column is of a type described in the preceding table, the types to which you can change the column by executing the ALTER TABLE table_name MODIFY/CHANGE COLUMN DDL statement in a MySQL database and a MySQL tenant of OceanBase Database are the same as those for a PRIMARY KEY column.

Change the type of a KEY column

If a KEY column is of a type described in the preceding table, the types to which you can change the column by executing the ALTER TABLE table_name MODIFY/CHANGE COLUMN DDL statement in a MySQL database and a MySQL tenant of OceanBase Database are the same as those for a PRIMARY KEY column.

Change the type of a FOREIGN KEY column

If a FOREIGN KEY column is of a type described in the preceding table, the types to which you can change the column by executing the ALTER TABLE table_name MODIFY/CHANGE COLUMN DDL statement in a MySQL database and a MySQL tenant of OceanBase Database are the same as those for a PRIMARY KEY column.

Change the type of a FULLTEXT indexed column

The following table describes the types to which you can change a FULLTEXT indexed column by executing the ALTER TABLE table_name MODIFY/CHANGE COLUMN DDL statement in a MySQL database and a MySQL tenant of OceanBase Database.

Column type in a MySQL database

Supported target type

Column type in a MySQL tenant of OceanBase Database

Supported target type

CHAR

All

CHAR

-

VARCHAR

All

VARCHAR

-

TINYTEXT

All

TINYTEXT

-

MEDIUMTEXT

All

MEDIUMTEXT

-

TEXT

All

TEXT

-

LONGTEXT

All

LONGTEXT

-

BINARY

-

VARBINARY

-

NCHAR

All

CHAR

-

JSON

All