This topic describes the supported conversion scope of ALTER TABLE DDL operations on constraints and indexes during data migration from a MySQL database to the MySQL compatible mode of OceanBase Database.
Syntax
alter_option: {
ADD {INDEX | KEY} [index_name]
[index_type] (key_part,...) [index_option] ...
| ADD {FULLTEXT | SPATIAL} [INDEX | KEY] [index_name]
(key_part,...) [index_option] ...
| ADD [CONSTRAINT [symbol]] PRIMARY KEY
[index_type] (key_part,...)
[index_option] ...
| ADD [CONSTRAINT [symbol]] UNIQUE [INDEX | KEY]
[index_name] [index_type] (key_part,...)
[index_option] ...
| ADD [CONSTRAINT [symbol]] FOREIGN KEY
[index_name] (col_name,...)
reference_definition
| ADD [CONSTRAINT [symbol]] CHECK (expr) [[NOT] ENFORCED]
| DROP {CHECK | CONSTRAINT} symbol
| ALTER {CHECK | CONSTRAINT} symbol [NOT] ENFORCED
| ALTER INDEX index_name {VISIBLE | INVISIBLE}
| {DISABLE | ENABLE} KEYS
| DROP {INDEX | KEY} index_name
| DROP PRIMARY KEY
| DROP FOREIGN KEY fk_symbol
| RENAME {INDEX | KEY} old_index_name TO new_index_name
}
key_part: {col_name [(length)] | (expr)} [ASC | DESC]
index_type:
USING {BTREE | HASH}
index_option: {
KEY_BLOCK_SIZE [=] value
| index_type
| WITH PARSER parser_name
| COMMENT 'string'
| {VISIBLE | INVISIBLE}
}
Supported operations
Use
ADD INDEX | KEYto create a normal index.Use
DROP INDEXto drop an index.Use
ADD FULLTEXT INDEX | KEYto create a full-text index.Use
ADD UNIQUE INDEX | KEYto create a unique index.Use
FOREIGN KEYto add a foreign key.Use
DROP PRIMARY KEYto drop a PRIMARY KEY constraint.Notice
Only OceanBase Database V4.0.0 and later versions support this operation.
Unsupported operations
Warning
If a DDL statement to be synchronized contains the following unsupported definitions, the conversion will fail and the output will be an empty string.
Create function-based indexes for UNIQUE KEY, INDEX/KEY, and FULLTEXT INDEX columns. You can create these indexes only on fields.
Use
ADD SPATIAL INDEX.Use
ADD PRIMARY KEY.Use
ALTER TABLE DISABLE | ENABLE KEYS.Specify the
ON [DELETE | UPDATE] SET NULLattribute forFOREIGN KEYcolumns.In the MySQL compatible mode of OceanBase Database of a version earlier than V3.2.3, you cannot perform the following operations:
Use
ADD CHECK.Use
DROP CHECK.Use
ALTER CHECK [NOT] ENFORCED.Use
ALTER INDEX VISIBLE | INVISIBLE.Use
RENAME INDEX | KEY.ALTER TABLE t rename KEY k TO kk; ALTER TABLE T RENAME INDEX b TO w;
Ignored clauses and options
Warning
The following clauses and options will be ignored and will not be resolved or converted when they are specified in the synchronized DDL statements.
USING BTREEorUSING HASHKEY_BLOCK_SIZE,index_type,WITH PARSER,COMMENT,VISIBLE | INVISIBLE,ENGINE_ATTRIBUTE, orSECONDARY_ENGINE_ATTRIBUTEinindex_option[NOT] ENFORCEDfor CHECK constraintsMATCH FULL | MATCH PARTIAL | MATCH SIMPLEforFOREIGN KEY
Limitations
Notice
Due to the limitations of the MySQL compatible mode of OceanBase Database, an error may be returned when the synchronized DDL statements are converted and executed in the MySQL compatible mode of OceanBase Database in the following scenarios.
The MySQL compatible mode of OceanBase Database does not support creating PRIMARY KEY, UNIQUE KEY, INDEX/KEY, FULLTEXT INDEX, or FOREIGN KEY constraints on specific types of fields.
The MySQL compatible mode of OceanBase Database does not support specifying certain functions or expressions in CHECK constraints.
The MySQL compatible mode of OceanBase Database does not support specifying certain functions or expressions in FOREIGN KEY constraints.