CASCADE
, SET NULL
, RESTRICT
, NO ACTION
, or SET DEFAULT
. You need to enable this check item first.NO ACTION
or RESTRICT
; otherwise, an error will occur, but you can choose whether to fix the error or ignore it and proceed with the task.NO ACTION
or RESTRICT
; otherwise, an error will occur, but you can choose whether to fix the error or ignore it and proceed with the task.ON DELETE
and ON UPDATE
columns:CASCADE
: When a record is deleted or updated in the parent table, its associated records will also be deleted or updated in the child table.SET NULL
: When a record is deleted or updated in the parent table, the column of the foreign key field of its associated records will be set to null
in the child table (child table foreign keys cannot be set to not null
).RESTRICT
: When a record is deleted or updated in the parent table, if it is associated with records in the child table, the deletion request in the parent table will be denied.NO ACTION
: Similar to RESTRICT
, the foreign key will be checked first.SET DEFAULT
: When a record is deleted or updated in the parent table, the foreign key column in the child table will be set to the default value, but the InnoDB engine cannot recognize it.CASCADE
, SET NULL
, RESTRICT
, NO ACTION
, or SET DEFAULT
.RESTRICT
and NO ACTION
by default. If the data migrated from the source database has other types of foreign key dependency configuration, the check system will report an error, and you need to enable foreign key dependency check as a check item as follows:CASCADE
, SET NULL
, and SET DEFAULT
, and an error is reported for the check item. You can view the details of the check item.Option | Description |
Ignore foreign key dependency check error | After this option is selected, the system will ignore existing check errors and proceed with the migration task. If the source database has foreign key rules CASCADE , SET NULL , or SET DEFAULT , the data can still be migrated, but the data results between the source and target databases may be inconsistent if data in the parent table is deleted or updated after errors are ignored. |
Migrate foreign key dependency | After this option is selected, CASCADE , SET NULL , and SET DEFAULT foreign key dependencies can be migrated, but DTS will check the foreign key dependencies only when a task is initiated to guarantee the consistency of the existing data migrated to the target database.1. During migration, do not modify the foreign key dependency check rule in the source database; otherwise, the data in the source and target databases will become inconsistent.
If you change the foreign key dependency check rule in the source database from CASCADE to NO ACTION during migration, updates and deletions performed on the parent table in the target database will still affect child tables.2. If the foreign key dependency check rule is CASCADE or SET NULL , after you select Migrate foreign key dependency, tables in the source database will be locked for about 5–10 seconds during full migration.3. To guarantee the data consistency, during incremental sync, the original row-level sync of data in foreign key-related tables will be downgraded to table-level, and the performance will decrease. |
NO ACTION
or RESTRICT
; otherwise, an error will occur, but you can choose whether to fix the error or ignore it and proceed with the task. You can fix the error as follows:NO ACTION
or RESTRICT
; otherwise, an error will occur, but you can choose whether to fix the error or ignore it and proceed with the task. You can fix the error as follows:alter table `table name 1` drop foreign key `foreign key name 1`;
alter table `table name 1` add constraint `foreign key name 2` foreign key `table name 1`(`column name 1`) references `table name 2`(`column name 1`)on update no action on delete no action;
Was this page helpful?