Create Data Comparison Task
Create a new data comparison task and specify the source, target, and the databases and tables to be compared.
Request URL: /openapi/v1/comparedata/create
Request Method: POST
Before You Call
sourceDsIdandtargetDsIdcan be obtained fromdata[].datasourceIdin Retrieve Data Source List.- If the data source has not been created yet, call Create Data Source first, then use
data.datasourceIdfrom the response. databaseName,targetDatabase,tableName, andtargetTablemust use the real database names and table names in the source and target instances.
Request Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| name | String | Yes | Task name. It is recommended to use a name that reflects the business purpose and comparison scope for easier follow-up queries. | compare-docx-proof-20260508163538 |
| sourceDsId | String | Yes | Source data source ID, which represents the baseline side of the comparison. You can get it from data[].datasourceId in Retrieve Data Source List. | ds-ct192k3jlj4f |
| targetDsId | String | Yes | Target data source ID, which represents the side compared against the source. You can get it from data[].datasourceId in Retrieve Data Source List. | ds-d37s953l33d3 |
| taskMode | String | Yes | Comparison type. The current example uses FULL, which means full comparison. | FULL |
| objectConfig | JSON | Yes | Comparison scope configuration. Use all, databaseList, and tableList together to define the instance, database, and table scope to compare. | See the example below |
objectConfig Fields
| Parameter | Type | Description | Example |
|---|---|---|---|
| all | Boolean | Whether to directly select all objects under the instance. If true, you do not need to specify databases or tables one by one. If false, you need to provide databaseList. | false |
| databaseList | Array | List of databases to compare. When multiple databases are needed, pass multiple objects in a JSON array. | [{...}] |
databaseList Fields
| Parameter | Type | Description | Example |
|---|---|---|---|
| databaseName | String | Source database name. It must match an actual database name in the instance identified by sourceDsId. | 9zdbtest2 |
| targetDatabase | String | Target database name. It must match an actual database name in the instance identified by targetDsId. | 9zdbtest3 |
| all | Boolean | Whether to compare all tables in the database. If true, all tables in the database are included. If false, you need to provide tableList. | true |
| tableList | Array | List of tables to compare. When multiple tables are needed, pass multiple objects in a JSON array. | [{...},{...}] |
tableList Fields
| Parameter | Type | Description | Example |
|---|---|---|---|
| tableName | String | Source table name. It must match an actual table name in the source database. | sbtest1 |
| targetTable | String | Target table name. It must match an actual table name in the target database. | sbtest1 |
How to Use the Returned Value
data in the successful response is the taskId created for this task. You need this value when calling Start Data Comparison Task, Query Data Comparison Main Task Details, Stop Data Comparison Task, and Delete Data Comparison Task.
Request Example
{
"name": "compare-docx-proof-20260508163538",
"objectConfig": {
"all": false,
"databaseList": [
{
"databaseName": "9zdbtest2",
"targetDatabase": "9zdbtest3",
"all": true,
"tableList": [
{
"tableName": "sbtest1",
"targetTable": "sbtest1"
},
{
"tableName": "sbtest2",
"targetTable": "sbtest2"
}
]
}
]
},
"sourceDsId": "ds-ct192k3jlj4f",
"targetDsId": "ds-d37s953l33d3",
"taskMode": "FULL"
}
Response Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| success | Boolean | Whether the request is successful. | true |
| requestId | String | Request ID, which can be used for troubleshooting and tracing. | Em1u9SHH-kqqraVGnllse6BZdmnh5DQM |
| data | String | Data comparison task ID, which is the taskId used by follow-up APIs. | cd-tepmjmnj6o |
Successful Invocation Example
{
"success": true,
"requestId": "Em1u9SHH-kqqraVGnllse6BZdmnh5DQM",
"data": "cd-tepmjmnj6o"
}