This topic describes the DDL operations supported for synchronization during incremental synchronization from an SQL Server database to an OceanBase database in MySQL or Oracle compatible mode, and the corresponding limitations.
Note
The support for DDL synchronization is subject to the general limitations of OMS. For details, see the "Considerations" section in DDL synchronization scope. The source DDL statements are for illustration only; the specific syntax shall be subject to the actual syntax supported by SQL Server.
Supported operations
When an SQL Server database serves as the source for incremental synchronization, OMS supports synchronizing the following DDL operations:
CREATE TABLEALTER TABLE, including onlyADD COLUMN,DROP COLUMN,ADD CONSTRAINT,DROP CONSTRAINT, and column modification operations that are supported by the target (modifying column type, column name, and column default value)DROP TABLECREATE INDEXDROP INDEX
DDL operations outside the above scope are not supported for synchronization to the target. DDL operations synchronized to the target will be converted according to the syntax of the corresponding compatible mode of OceanBase Database before execution.
The following source operations are explicitly not within the supported scope:
TRUNCATE TABLE: After CDC is enabled for an SQL Server table, the table itself refuses to executeTRUNCATE TABLE, and OMS cannot synchronize this operation. To clear table data, useDELETEinstead and assess the impact on synchronization latency.RENAME TABLEand renaming tables usingsp_rename: OMS captures this operation but does not synchronize it to the target. After the source table name changes, the original table name remains in the target. Please adjust the mapping relationship of migration objects. For details, see View and modify migration objects.
Notice
Do not perform DDL operations that modify database or table structures during schema migration or full migration. Otherwise, it may cause object structure inconsistency, full data load failure, or interruption of the data migration task.
Before performing DDL operations in a production environment, comply with the restrictions on production DDL execution described in the "Considerations" section of the link. For details, see Migrate data from an SQL Server database to the MySQL-compatible mode of OceanBase Database or Migrate data from an SQL Server database to the Oracle-compatible mode of OceanBase Database.
CREATE TABLE
Create a table
CREATE TABLE T (C INT);
Note
The CREATE TABLE statement is synchronized to the target only if migration objects are selected by using the matching rules method and the name of the new table is included in the migration object rule. OMS creates a CDC capture instance for the new table before synchronizing the CREATE TABLE statement. If migration objects are selected by using the specified objects method, synchronizing the CREATE TABLE statement is not supported.
ALTER TABLE
Add a column
ALTER TABLE T ADD C2 INT; ALTER TABLE T ADD C2 INT NOT NULL DEFAULT 1;Notice
The preceding
DEFAULT 1is an example of a constant default value. If the default value of a newly added column is calculated separately at the source and target (for example,ALTER TABLE T ADD rowguid UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID()), the values generated for existing rows may differ between the two sides, leading to data inconsistency. Businesses that rely on such identifiers should avoid using this method to add a column, or switch only after confirming that the values are consistent across both sides.Drop a column
ALTER TABLE T DROP COLUMN C2;Add a constraint
ALTER TABLE T ADD CONSTRAINT UK_C UNIQUE (C); ALTER TABLE T ADD CONSTRAINT PK_T PRIMARY KEY (C); ALTER TABLE T ADD CONSTRAINT FK_T_C FOREIGN KEY (C) REFERENCES P(COL1); ALTER TABLE T ADD CONSTRAINT CK_T_C CHECK (C > 0);Note
The synchronization effect of different constraints depends on the target compatibility mode:
CHECKconstraints are synchronized in both target modes.FOREIGN KEYconstraints are synchronized in OceanBase Database's MySQL-compatible mode; however, foreign keys are not created at the target in OceanBase Database's Oracle-compatible mode.The addition and deletion of
PRIMARY KEYandUNIQUEconstraints can be synchronized. However, changing DDL operations that modify primary key or unique key configurations (for example, firstDROP CONSTRAINTto drop the primary key, thenADD CONSTRAINTto recreate it) is not supported. For details, see the note following "Delete a constraint" below.
Delete a constraint
ALTER TABLE T DROP CONSTRAINT UK_C;
Notice
OMS does not support synchronizing DDL operations that modify primary key or unique key configurations, such as first DROP CONSTRAINT to drop the primary key, then ADD CONSTRAINT to recreate it. Such changes may lead to inaccurate incremental positioning and data quality issues.
Note
Column modification operations such as changing the column type, renaming the column, and modifying the column's default value can be synchronized to the target if supported. Other options of ALTER TABLE, such as adding or dropping indexes, are not supported for synchronization to the target. Index creation and deletion should be synchronized using CREATE INDEX and DROP INDEX.
DROP TABLE
Drop a table.
DROP TABLE T1,T2;
CREATE INDEX
Create a normal index or a unique index.
CREATE INDEX IDX_C ON T(C);
CREATE UNIQUE INDEX IDX_C ON T(C);
Note
The table object containing the index must be within the migration object rules for the related DDL to be synchronized to the target. Clustered indexes, filtered indexes, and unique and non-unique indexes in SQL Server are all converted into normal indexes in the corresponding compatible mode of OceanBase Database.
DROP INDEX
Drop an index.
DROP INDEX IDX_C ON T;
OceanBase Database to SQL Server Database
During the reverse incremental phase, the DDL types that can be selected in the Customize Synchronization Scope panel are: CREATE, ALTER, DROP, RENAME, and TRUNCATE for tables, and CREATE and DROP for indexes.
Note
The values in this section apply only to the reverse incremental phase and differ from those described in the "Supported Scope Overview" section above for forward incremental synchronization: forward incremental synchronization does not support synchronizing TRUNCATE TABLE or RENAME TABLE from the source SQL Server to the target. In the reverse incremental phase, you can select RENAME and TRUNCATE in Custom Synchronization Scope.
In a reverse incremental scenario, the scope of supported incremental DDL operations from OceanBase Database to SQL Server Database is limited. Known limitations include:
Reverse incremental synchronization from OceanBase Database in Oracle compatible mode to SQL Server Database does not support synchronizing
DROP INDEX.During reverse synchronization of
DROP COLUMN, if the target column in SQL Server is still referenced by a default value, constraint, or index, OMS fails when replaying the DDL in SQL Server.When adding a NOT NULL column to a table with existing data on the target side, SQL Server requires the column to have a default value; otherwise, OMS fails when replaying the DDL in SQL Server. This restriction does not apply in OceanBase Database in MySQL compatible mode.
During reverse synchronization of column modification operations, SQL Server requires explicitly retaining the
NOT NULLattribute; otherwise, the column will become nullable. OceanBase Database in Oracle compatible mode does not support setting column attributes simultaneously when configuring this change, and such incremental DDL will report an error.Reverse incremental synchronization does not support ETL configuration.
It is recommended to check the required DDL for the reverse link and the dependency relationships of target columns before business switchover, and to arrange manual processing for unsupported changes in advance.