Change the length of a constrained column

2024-12-13 06:57:09  Updated

This topic describes incompatibilities between MySQL databases and MySQL tenants of OceanBase Database when you change the length 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, and a hyphen (-) means N/A.

Change the length of a PRIMARY KEY column

The following table describes the operations that you can perform to change the length of 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 Allowed operation Column type in a MySQL tenant of OceanBase Database Allowed operation
INT Increase and decrease the length INTEGER Increase and decrease the length
TINYINT Increase and decrease the length TINYINT Increase and decrease the length
SMALLINT Increase and decrease the length SMALLINT Increase and decrease the length
MEDIUMINT Increase and decrease the length MEDIUMINT Increase and decrease the length
BIGINT Increase and decrease the length BIGINT Increase and decrease the length
BOOL - BOOLEAN -
DECIMAL Increase and decrease the length DECIMAL Increase the length
NUMERIC Increase and decrease the length NUMERIC Increase the length
REAL Increase and decrease the length FLOAT Increase and decrease the length
DOUBLE Increase and decrease the length DOUBLE Increase and decrease the length
FLOAT Increase and decrease the length FLOAT Increase and decrease the length
BIT Increase and decrease the length BIT Increase and decrease the length
CHAR Increase and decrease the length CHAR Increase the length
NCHAR Increase and decrease the length CHAR Increase the length
VARCHAR Increase and decrease the length VARCHAR Increase the length
BINARY Increase and decrease the length BINARY -
VARBINARY Increase and decrease the length VARBINARY Increase the length
LONG VARBINARY -
YEAR Increase and decrease the length YEAR Increase the length (the length is fixed to be 4 bytes)
DATE - DATE -
TIME Increase and decrease the length TIME Increase the length
TIMESTAMP Increase and decrease the length TIMESTAMP Increase the length
DATETIME Increase and decrease the length DATETIME Increase the length
TINYBLOB -
MEDIUMBLOB -
BLOB -
LONGBLOB -
TINYTEXT -
MEDIUMTEXT -
TEXT -
LONGTEXT -
ENUM Increase and decrease the length ENUM Increase the length
SET Increase and decrease the length SET Increase the length
JSON -

Change the length of a UNIQUE KEY column

If a UNIQUE KEY column is of a type described in the preceding table, the operations that you can perform to change the column length 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 length of a KEY column

If a KEY column is of a type described in the preceding table, the operations that you can perform to change the column length 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 length of a FOREIGN KEY column

The following table describes the operations that you can perform to change the length of a FOREIGN 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 Allowed operation Column type in a MySQL tenant of OceanBase Database Allowed operation
INT Increase and decrease the length INTEGER Increase and decrease the length
TINYINT Increase and decrease the length TINYINT Increase and decrease the length
SMALLINT Increase and decrease the length SMALLINT Increase and decrease the length
MEDIUMINT Increase and decrease the length MEDIUMINT Increase and decrease the length
BIGINT Increase and decrease the length BIGINT Increase and decrease the length
BOOL - BOOLEAN -
DECIMAL - DECIMAL Increase the length
NUMERIC - NUMERIC Increase the length
REAL Increase and decrease the length FLOAT Increase and decrease the length
DOUBLE Increase and decrease the length DOUBLE Increase and decrease the length
FLOAT Increase and decrease the length FLOAT Increase and decrease the length
BIT - BIT Increase and decrease the length
CHAR - CHAR Increase the length
NCHAR - CHAR Increase the length
VARCHAR Increase the length VARCHAR Increase the length
BINARY - BINARY -
VARBINARY Increase the length VARBINARY Increase the length
LONG VARBINARY -
YEAR - YEAR Increase the length (the length is fixed to be 4 bytes)
DATE - DATE -
TIME - TIME Increase the length
TIMESTAMP - TIMESTAMP Increase the length
DATETIME - DATETIME Increase the length
TINYBLOB -
MEDIUMBLOB -
BLOB -
LONGBLOB -
TINYTEXT -
MEDIUMTEXT -
TEXT -
LONGTEXT -
ENUM Increase the length ENUM Increase the length
SET Increase the length SET Increase the length
JSON -

Change the length of a FULLTEXT-indexed column

The following table describes the operations that you can perform to change the length of 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 Allowed operation Column type in a MySQL tenant of OceanBase Database Allowed operation
CHAR Increase and decrease the length CHAR -
VARCHAR Increase and decrease the length VARCHAR -
TINYTEXT - TINYTEXT -
MEDIUMTEXT - MEDIUMTEXT -
TEXT - TEXT -
LONGTEXT - LONGTEXT -
BINARY -
VARBINARY -
NCHAR Increase and decrease the length CHAR -
JSON -

Contact Us