Skip to main content

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

  • sourceDsId and targetDsId can be obtained from data[].datasourceId in Retrieve Data Source List.
  • If the data source has not been created yet, call Create Data Source first, then use data.datasourceId from the response.
  • databaseName, targetDatabase, tableName, and targetTable must use the real database names and table names in the source and target instances.

Request Parameters

ParameterTypeRequiredDescriptionExample
nameStringYesTask 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
sourceDsIdStringYesSource 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
targetDsIdStringYesTarget 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
taskModeStringYesComparison type. The current example uses FULL, which means full comparison.FULL
objectConfigJSONYesComparison scope configuration. Use all, databaseList, and tableList together to define the instance, database, and table scope to compare.See the example below

objectConfig Fields

ParameterTypeDescriptionExample
allBooleanWhether 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
databaseListArrayList of databases to compare. When multiple databases are needed, pass multiple objects in a JSON array.[{...}]

databaseList Fields

ParameterTypeDescriptionExample
databaseNameStringSource database name. It must match an actual database name in the instance identified by sourceDsId.9zdbtest2
targetDatabaseStringTarget database name. It must match an actual database name in the instance identified by targetDsId.9zdbtest3
allBooleanWhether to compare all tables in the database. If true, all tables in the database are included. If false, you need to provide tableList.true
tableListArrayList of tables to compare. When multiple tables are needed, pass multiple objects in a JSON array.[{...},{...}]

tableList Fields

ParameterTypeDescriptionExample
tableNameStringSource table name. It must match an actual table name in the source database.sbtest1
targetTableStringTarget 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

ParameterTypeDescriptionExample
successBooleanWhether the request is successful.true
requestIdStringRequest ID, which can be used for troubleshooting and tracing.Em1u9SHH-kqqraVGnllse6BZdmnh5DQM
dataStringData 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"
}