Call DTS API operations to configure or query migration, synchronization, and subscription objects. Covers object definitions, parameters, and configuration examples.
Related API operations and parameters
|
API |
Description |
|
Configure objects in the |
|
|
Query objects in the |
Definition of migration, synchronization, or subscription objects
Object-related parameters use JSON strings. The following section describes available parameters.
-
When objects include multiple databases:
ImportantSubscription instances do not support mapping. The
nameparameter value must match the actual database or table name.{ "Name of database 1 to be migrated, synchronized, or subscribed to": { "name": "Name of database 1 in the destination instance", "all": true (Indicates that the entire database is migrated, synchronized, or subscribed to) }, "Name of database 2 to be migrated, synchronized, or subscribed to": { "name": "Name of database 2 in the destination instance", "all": false (Indicates that the entire database is not migrated, synchronized, or subscribed to), "Table": { "Name of table A to be migrated, synchronized, or subscribed to": { "name": "Name of table A in the destination instance", "all": true (Indicates that the entire table is migrated, synchronized, or subscribed to), "dml_op": "DML operations to be incrementally migrated or synchronized", "ddl_op": "DDL operations to be incrementally migrated or synchronized" } } }, "Name of database 3 to be migrated, synchronized, or subscribed to": { "name": "Name of database 3 in the destination instance", "all": true (Indicates that the entire database is migrated, synchronized, or subscribed to), "dml_op": "DML operations to be incrementally migrated or synchronized", "ddl_op": "DDL operations to be incrementally migrated or synchronized" } } -
When objects are at the column level or include filter conditions:
{ "Name of database to be migrated, synchronized, or subscribed to": { "name": "Name of database in the destination instance", "all": false (Indicates that the entire database is not migrated, synchronized, or subscribed to), "Table": { "Name of table A to be migrated, synchronized, or subscribed to": { "name": "Name of table A in the destination instance", "all": false (Indicates that the entire table is not migrated, synchronized, or subscribed to), "filter": "id>10" "column": { "id": { "key": "PRI", "name": "id", "type": "int(11)", "sharedKey": false, "state": "checked" } }, "shard": 12 } } } } -
When the destination is AnalyticDB for MySQL or AnalyticDB for PostgreSQL:
{ "Name of database to be migrated or synchronized": { "name": "Name of database in the destination instance", "all": false (Fixed as false. Regardless of whether the objects are at the database or table level, if the destination instance is AnalyticDB for MySQL or AnalyticDB for PostgreSQL, this parameter is fixed as false, and you must also specify information such as the partition key of the table), "Table": { "Name of table A to be migrated or synchronized": { "all": true (Indicates that the entire table is migrated or synchronized), "name": "Name of table A in the destination instance", "primary_key": "id (Specifies the primary key)", "type": "dimension (Type of the table)", } "Name of table B to be migrated or synchronized": { "all": true (Indicates that the entire table is migrated or synchronized), "name": "Name of table B in the destination instance", "part_key": "id (Specifies the partition key)", "primary_key": "id (Specifies the primary key)", "type": "partition (Type of the table)", "tagColumnValue": "Value of the tag column" } } } } -
When you set independent conflict resolution policies for synchronization objects:
Note-
This feature is supported only for bidirectional synchronization instances between MySQL instances or between PolarDB for MySQL clusters.
-
You can set independent conflict resolution policies at the database or table level.
-
For columns that are configured with an independent conflict resolution policy, the global conflict resolution policy does not take effect.
Table-level settings
{ "Name of database 1 to be synchronized": { "name": "Name of database 1 in the destination instance", "all": true (Indicates that the entire database is synchronized), "conflict": "Task-level conflict resolution policy" }, "Name of database 2 to be synchronized": { "name": "Name of database 2 in the destination instance", "all": false (Indicates that the entire database is not synchronized), "conflict": "overwrite", "Table": { "Name of table A to be synchronized": { "name": "Name of table A in the destination instance", "all": true (Indicates that the entire table is synchronized), "cdr_cmp_col": "Conflict detection column", "cdr_rslv_col": "Conflict detection column", "resolve_method": "Table-level conflict resolution policy" } } } }Database-level settings
-
When the synchronization object is an entire database:
"Name of database 1 to be synchronized": { "name": "Name of database 1 in the destination instance", "all": true (Indicates that the entire database is synchronized), "conflict": "Task-level conflict resolution policy", "cdr_cmp_col": "Conflict detection column", "cdr_rslv_col": "Conflict detection column", "resolve_method": "Database-level conflict resolution policy" } } -
When the synchronization object is not an entire database:
"Name of database 2 to be synchronized": { "name": "Name of database 2 in the destination instance", "all": false (Indicates that the entire database is not synchronized), "conflict": "Task-level conflict resolution policy", "cdr_cmp_col": "Conflict detection column", "cdr_rslv_col": "Conflict detection column", "resolve_method": "Database-level conflict resolution policy", "Table": { "Name of table A to be synchronized": { "name": "Name of table A in the destination instance", "all": true (Indicates that the entire table is synchronized) } } }
-
-
When you configure a data integration task to a data lake:
Parameter
Description
write_operationThe write method when a data conflict occurs.
-
append: Retains existing data and adds new data. -
overwrite: Overwrites conflicting data in the destination. -
errorIfExists: The task reports an error and exits. -
ignore: Skips the current write and retains existing data in the destination.
targetTypeThe data format after writing to OSS (forced conversion). Supported formats:
Byte,Integer,Long,Double,String,Binary,Boolean,Timestamp, andDate.NoteIf not specified, DTS automatically converts source data types.
etl_dateThe name of the additional column (constant) to be added.
NoteThe values of the two
etl_dateparameters must be the same.syntacticTypeFixed as ADD, which indicates that a column is added.
NoteThe added column value (
value) must be a constant enclosed in single quotation marks ('').part_keyThe partition key of the destination table. Two possible values:
NoteRequired only when the destination table is partitioned.
-
A column to be integrated from the source.
-
A constant column added to the destination and set as the partition key.
NoteThe format is
<Key>=<Value>. For example,dt=2025-07-07indicates a constant column nameddtwith a value of2025-07-07.
{ "Name of database 1 to be integrated": { "all": false (Fixed as false), "Table": { "Name of table A to be integrated": { "all": false (Indicates that the entire table is not integrated), "filter": "", "write_operation": "Method used to write data", "name": "Name of table A in the destination instance", "column": { "Name of column a to be integrated": { "name": "Name of column a in the destination instance", "targetType": "Type of the column in OSS" }, ******, "etl_date": { "syntacticType": "ADD (Fixed as ADD)", "name": "etl_date", "type": "String (Fixed as String)", "value": "'2025-07-08 03:30:00'" } }, "part_key": "dt=2025-07-07" } }, "name": "dtstestdata (Name of database 1 in the destination instance)" } } -
|
Parameter |
Description |
|
|
The mapped name of the source database, table, or column in the destination. For example, to migrate database dtssource to dtstarget, set this parameter to dtstarget. |
|
|
Specifies whether to select all tables or columns. Valid values:
|
|
|
The information of the source table. |
|
|
The filter condition for data to migrate, synchronize, or subscribe to. Can only be set at the table level. For example, you can set this parameter to Note
Subscription tasks do not support setting filter conditions. |
|
|
The information of the source column. |
|
|
Specifies whether the column is a primary key. Valid values:
|
|
|
Specifies whether the column is a shard key. Valid values:
Note
Required only when the database type is Kafka. |
|
|
The data type of the field. |
|
|
If the value is |
|
|
The shard count for the table to migrate or synchronize. Note
Required only when the database type is Kafka. |
|
|
DML operations to incrementally migrate or synchronize. Valid values:
Note
For supported DML operations per task type, check the configuration documents in Migration solutions or Synchronization solutions. |
|
|
DDL operations to incrementally migrate or synchronize. Valid values:
Note
For supported DDL operations per task type, check the configuration documents in Migration solutions or Synchronization solutions. |
|
|
The primary key. Required only when the destination is AnalyticDB for MySQL or AnalyticDB for PostgreSQL. |
|
|
The partition key. Required when the destination is AnalyticDB for MySQL or AnalyticDB for PostgreSQL. |
|
Important
This |
The table type when the destination is AnalyticDB for MySQL or AnalyticDB for PostgreSQL. Valid values:
|
|
|
The custom value of the __dts_data_source tag column. Required when the destination is AnalyticDB for MySQL. |
|
|
The task-level global conflict resolution policy. Must be included in each database to synchronize with the same value. Valid values:
|
|
|
The table-level independent conflict resolution policy. Only supported for incremental synchronization. Valid values:
|
|
|
|
|
|
Configuration examples
-
Example 1: Migrate, synchronize, or subscribe to all tables in the dtstestdata database.
{"dtstestdata": { "name": "dtstestdata", "all": true }} -
Example 2: Migrate or synchronize the dtstestdata database and rename it to dtstestdata_new.
{"dtstestdata": { "name": "dtstestdata_new", "all": true }} -
Example 3: Migrate, synchronize, or subscribe to specific tables (such as customer) in the dtstestdata database.
{"dtstestdata": { "name": "dtstestdata", "all": false, "Table": { "customer": { "name": "customer", "all": true, "column": { "id": { "key": "PRI", "name": "id", "type": "int(11)", "sharedKey": false, "state": "checked" }, "gmt_create": { "key": "", "name": "gmt_create", "type": "datetime", "sharedKey": false, "state": "checked" }, "gmt_modify": { "key": "", "name": "gmt_modify", "type": "datetime", "sharedKey": false, "state": "checked" }, "valid_time": { "key": "", "name": "valid_time", "type": "datetime", "sharedKey": false, "state": "checked" }, "creator": { "key": "", "name": "creator", "type": "varchar(200)", "sharedKey": false, "state": "checked" } }, "shard": 12 } } } } -
Example 4: Migrate or synchronize specific columns of tables (such as customer and order) in the dtstestdata database.
{"dtstestdata": { "name": "dtstestdata", "all": false, "Table": { "customer": { "name": "customer", "all": false, "column": { "id": { "key": "PRI", "name": "id", "type": "int(11)", "sharedKey": false, "state": "checked" }, "level": { "key": "", "name": "level", "type": "varchar(5000)", "sharedKey": false, "state": "checked" }, "name": { "key": "", "name": "name", "type": "varchar(500)", "sharedKey": false, "state": "checked" }, }, "shard": 12 }, "order": { "name": "order", "all": false, "column": { "id": { "key": "PRI", "name": "id", "type": "int(11)", "sharedKey": false, "state": "checked" } }, "shard": 12 } } } } -
Example 5: Migrate or synchronize tables (such as customer, order, and commodity) from the dtstestdata database to a destination AnalyticDB for MySQL or AnalyticDB for PostgreSQL instance.
{ "dtstestdata": { "name": "dtstestdatanew", "all": false, "Table": { "order": { "name": "ordernew", "all": true, "part_key": "id", "primary_key": "id", "type": "partition" }, "customer": { "name": "customernew", "all": true, "primary_key": "id", "type": "dimension" }, "commodity": { "name": "commoditynew", "all": false, "filter": "id>10", "column": { "id": { "key": "PRI", "name": "id", "type": "int(11)" } }, "part_key": "id", "primary_key": "id", "type": "partition" } } } } -
Example 6: Set independent conflict resolution policies for synchronization objects.
Table-level settings
Set the global conflict resolution policy for the synchronization task objects to
interrupt. Set the independent conflict resolution policy for the primary key columns, unique key columns, andnamecolumn of the customer table in the dtstestdata2 database tooverwrite.{ "dtstestdata1": { "name": "dtstestdata1", "all": true, "conflict": "interrupt" }, "dtstestdata2": { "name": "dtstestdata2", "all": false, "conflict": "interrupt", "Table": { "customer": { "name": "customer", "all": true, "cdr_cmp_col": "name", "cdr_rslv_col": "name", "resolve_method": "overwrite" } } } }Database-level settings
-
When the synchronization object is an entire database: Set the independent conflict resolution policy for the
nameandaddrcolumns of all tables to be synchronized in the dtstestdata1 database touse_max."dtstestdata1": { "name": "dtstestdata1", "all": true, "conflict": "overwrite", "cdr_cmp_col": "name,addr", "cdr_rslv_col": "name,addr", "resolve_method": "use_max" } } -
When the synchronization object is not an entire database: Set the independent conflict resolution policy for the
nameandaddrcolumns of all tables to be synchronized in the dtstestdata2 database touse_max."dtstestdata2": { "name": "dtstestdata2", "all": false, "conflict": "overwrite", "cdr_cmp_col": "name,addr", "cdr_rslv_col": "name,addr", "resolve_method": "use_max", "Table": { "person": { "name": "person", "all": true }, "class": { "name": "class", "all": true } } }
-
-
Example 7: For a synchronization instance where the source database type is Tair/Redis, synchronize only data with the key prefix
HPropfrom DBs named 0 and 1 (that is, the Prefixes of Keys to Be Synchronized isHProp). For the DB named 2, synchronize only data with the key prefixdtsbut not includingdtstest(that is, the Prefixes of Keys to Be Synchronized isdts, and the Prefixes of Keys to Be Filtered Out isdtstest).{ "0": { "name": "0", "all": true, "filter": "[{"condition":"HProp","filterType":"white","filterPattern":"prefix"}]" }, "1": { "name": "1", "all": true, "filter": "[{"condition":"HProp","filterType":"white","filterPattern":"prefix"}]" }, "2": { "name": "2", "all": true, "filter": "[{"condition":"dts","filterType":"white","filterPattern":"prefix"},{"condition":"dtstest","filterType":"black","filterPattern":"prefix"}]" } } -
Example 8: Integrate the commodity table in the dtstestdata database into the destination OSS in Delta format.
{ "dtstestdata(": { "all": false, "Table": { "commodity": { "all": false(), "filter": "", "write_operation": "overwrite", "name": "commodity", "column": { "IS_VALID": { "name": "is_valid", "targetType": "String" }, "BuiltinArchiveDate": { "name": "builtinarchivedate", "targetType": "String" }, "PRODUCT_NAME": { "name": "product_name", "targetType": "String" }, "PRODUCT_CODE": { "name": "product_code", "targetType": "String" }, "etl_date": { "syntacticType": "ADD", "name": "etl_date", "type": "String", "value": "'2025-07-08 03:30:00'" } }, "part_key": "dt=2025-07-07" } }, "name": "dtstestdata" } }