tencent cloud

Database Management Center

Structure Comparison

PDF
Focus Mode
Font Size
Last updated: 2026-04-16 15:41:00
When you need to compare fields, indexes, comments, and sequences of databases, tables, and views across different database instances, you can view the comparison results by creating a comparison task and selecting instances, comparison types, and objects. Through visual instance structure comparisons, you can efficiently analyze changes in the database structure, ensuring the high-efficiency operation, compliance, and reliability of the database system.
Structure comparison also supports viewing the comparison task list, checking task details, and starting, restarting, copying, terminating, deleting, and downloading comparison tasks.

Introduction to Structure Comparison Types and Comparison Modes

Comparison objects can be databases, tables, and views. Different comparison types support different comparison objects. Comparison types and comparison modes can be freely combined. You may make a selection as required.

Comparison Type

Comparison Type
Comparison Object
Free comparison
Compare between tables or views.
Database-Level Comparison
Only compare the fields of tables with the same name in databases.

Comparison Mode

Comparison Mode
Description
Simple Mode
Only compare field names, types, indexes, and default values. Order and remarks are not within the scope of comparison.
Strict Mode
Compare all fields, indexes, remarks, and order.

Implementation Logic


1. First, select the source and target instances to be compared, as well as the comparison mode (simple mode or strict mode), comparison type (free comparison or database-level comparison), and comparison object.
2. After the comparison task is initiated, DMC will sequentially perform connectivity checks (including account password and security group) and advanced permission checks on the selected source and target instances in the task.
3. After a successful check, the table structure of the comparison object is obtained through show create table db_name.table_name, and a structural task is executed according to the comparison mode, comparison type, and comparison object selected by the user. During the execution of comparison tasks, up to 10 sessions can be concurrently active for both source and target instances.
4. Generate comparison results, that is, whether the comparison structures are consistent.
5. In case of inconsistencies in the comparison results, you can choose to generate change SQL. During the generation of change SQL, previously saved snapshots of the table structures during the structure comparison task are read, and change SQL is produced through internal logic.

Impact Description

Since a single comparison task may initiate up to 10 sessions for both the source and target instances, you should try to perform comparison tasks during periods of low load to minimize the impact on user instances. Additionally, it is recommended not to start multiple comparison tasks simultaneously on a single instance.
The session connection timeout established while obtaining table structures during the execution of structure comparison tasks is 3 seconds, which means it will not occupy the user instance's connections for a long time. Other operations during the execution of structure comparison tasks and the process of generating change SQL are carried out on the DMC side, which will not increase resource load on the user instance side.
The structure comparison feature does not read or modify any data saved in the database by users.

Use Limits

Generating change SQL operations is supported only when the number of table fields in both the source and target instances is less than 500.
The generation of change SQL is based on the snapshot of the table structure captured at the time of task initiation, not on real-time acquisition.
During the generation of change SQL, the process of renaming columns cannot be detected. If there are renamed columns, you should verify them carefully.

Prerequisites

The instances to be compared have been added to the data source. For detailed operations, see Create Data Source.
If the instance to be compared is in the control mode, the comparison is only supported for databases and tables to which you have access. To compare additional databases and tables, you should request the necessary permissions first. For detailed operations, see Permission Application.

Creating a Structure Comparison Task

1. Log in to the DMC console.
2. In the left sidebar, select Advanced Development > Structure Comparison.
3. Click Create Structure Comparison at the top of the page.
4. Select a target.
Parameter
Description
Task Name
Enter the comparison task name.
Only numbers, uppercase and lowercase English letters, Chinese characters, and special characters such as _, -, ., /, (), and [] are supported, with a length less than 60.
Source Instance
Select the source instance name, that is, the data source name and ID.
Target Instances
Select one or two target instance names, that is, the data source name and ID.
Comparison Mode
Select the comparison mode. Simple mode and strict mode are supported.
Simple mode: Only compare field names, types, indexes, and default values. Order and remarks are not within the scope of comparison.
Strict mode: Compare all fields, indexes, remarks, and order.
5. Click Next to proceed with the comparison configuration.

5.1 Select a comparison type. Free comparison and database-level comparison are supported.
Free comparison: Compare between tables or views.
Database-level comparison: Only compare the fields of tables with the same name in databases.
5.2 Click Add, then in the pop-up dialog box, select the tables or views to be compared from both the source instance and target instance. After selection, click Add Comparison Object. You can add multiple pairs of comparison objects. After addition, click OK.
Selection of comparison objects for free comparison.

Selection of comparison objects for database-level comparison.

5.3 Click Create Now. This will complete the creation of the comparison task.

6. Enter the pre-check phase, and click Start Comparison.
Notes:
After creating a comparison task, if you do not want to start comparing immediately, you can click Start Comparison in the operation column of the comparison task list later to initiate pre-check and comparison tasks.
After starting the comparison, the system will first check the instance status and information automatically. If the check passes, the comparison task will be executed automatically. If the check fails, it will notify you of the failed instances and the failure reasons. Failure reasons include but are not limited to instances not existing, incorrect instance username or password, lack of operation permissions on the instance or database, or not being a high-level permission user.

7. View pre-check results.
Pre-check passed: Automatically execute the comparison task.

Click View Details to enter the details page of the comparison task.
Click View List to navigate to the structure comparison task list.
Pre-check failed: The comparison task can be restarted after modifying it according to the indicated failure reason.
Returning to the previous configuration page or re-comparing is allowed.

Viewing the Comparison Task List

1. Log in to the DMC console.
2. In the left sidebar, select Advanced Development > Structure Comparison.
3. Select the time range in the upper-right corner of the page. Options include Today, Yesterday, Last 7 Days, Last 30 Days, and custom periods.
4. (Optional) You can filter and query comparison tasks by resource attribute.
5. View the comparison task list. The parameters in the list are described in the table below.

Parameter
Description
Task ID/Name
The ID and name of the structure comparison task.
Click a task ID to enter the task details page.
Type Comparison
Free comparison and database-level comparison are supported.
Free comparison: Compare between tables or views.
Database-level comparison: Compare only based on the fields of all tables and views in the database.
Comparison Mode
Simple mode and strict mode are supported.
Simple mode: Only compare field names, types, indexes, and default values. Order and remarks are not within the scope of comparison.
Strict mode: Compare all fields, indexes, remarks, and order.
Source Instance
The ID and name of the source instance selected for the comparison task.
Target Instances
The ID and name of the target instance selected for the comparison task.
Initiator
The username of the person who created the comparison task.
Creation Time
The creation time of a comparison task.
Status
The status of the comparison task, which includes To be Started, Checking, Check Completed, To Be Executed, Executing, Terminated, Execution Failed, and Completed.
Operation
View Comparison Details: Click View to enter the details page of the comparison task. For specific instructions and operations, see Viewing Comparison Task Details.
Start Comparison: Click Start Comparison to immediately initiate the pre-check and comparison task. For detailed operations, see Starting a Comparison Task.
Compare Again: Click Compare Again to restart the pre-check and comparison task. For detailed operations, see Restarting a Comparison Task.
Copy Comparison Task: Click More > Copy Task. For detailed operations, see Copying a Comparison Task.
Terminate Comparison Task: Click More > Terminate. For detailed operations, see Terminating a Comparison Task.
Delete Comparison Task: Click More > Delete. For detailed operations, see Deleting a Comparison Task.

Viewing Comparison Task Details

1. Log in to the DMC console.
2. In the left sidebar, select Advanced Development > Structure Comparison.
3. Click View in the Operation column corresponding to the comparison task to be viewed, or click the task ID.
4. View task details.
Free comparison example

Database-level comparison example

Basic information
You can view the task ID, task name, comparison type, comparison mode, initiator, status, comparison result, creation time, end time, and other information.
Comparison detail
You can view the source instance and target instance names, comparison type, comparison result, and task status. Click View in the operation column to check the comparison details and generate change SQL.

View detailed comparison results
Detailed comparison results can be viewed in the pop-up box on the right.
Generate changed SQL
Click Generate Changed SQL at the top of the page to generate an SQL statement that changes the target table in the task to be exactly the same as the source table SQL.

Notes:
The change SQL is for reference only. You should check carefully when applying it in practice. Known limitations include:
Currently, the process of column renaming cannot be perceived. If there are renamed columns, carefully verify and delete the relevant DROP/ADD statements.
Currently, the optimal change SQL cannot be generated for some scenarios. You should carefully check the generated results.
Click Re-compare at the top of the page to re-execute comparison tasks with statuses of Completed, Check Failed, Execution Failed, or Terminated.
Click Copy Task at the top of the page to copy the parameter information configured for the current task. You can modify the parameter configuration information and create a comparison task.
Click Terminate at the top of the page to terminate comparison tasks with statuses of Executing or To Be Executed.

Starting a Comparison Task

If a comparison task is created but not started immediately, and you now need to start the comparison, follow the steps Below. When the status of the comparison task is To be Started, you can start the comparison.
1. Log in to the DMC console.
2. In the left sidebar, select Advanced Development > Structure Comparison.
3. In the Operation column corresponding to the comparison task, click Start Comparison to initiate the pre-check and comparison task.
Additionally, you can click View in the Operation column corresponding to the comparison task or click the task ID. This will take you to the comparison task details page, where you can click Start Comparison.
4. Click View in the operation column of the comparison task to check the status and details of the comparison task.

Restarting a Comparison Task

You can restart a comparison task with the status of Completed, Execution Failed, Check Failed, or Terminated.
1. Log in to the DMC console.
2. In the left sidebar, select Advanced Development > Structure Comparison.
3. In the Operation column corresponding to the comparison task, click Re-compare to initiate the pre-check and comparison task.
Additionally, you can click View in the Operation column corresponding to the comparison task or click the task ID, and click Re-compare on the comparison task details page.
4. Click View in the operation column of the comparison task to check the status and details of the comparison task.

Copying a Comparison Task

You can create a comparison task by copying an existing one and modifying its configuration parameters.
1. Log in to the DMC console.
2. In the left sidebar, select Advanced Development > Structure Comparison.
3. In the Operations column corresponding to the comparison task, click More > Copy Task.
Additionally, you can click View in the Operation column corresponding to the comparison task or click the task ID, and click Copy Task on the comparison task details page.
4. Based on the existing configuration parameters, modify the selected target and comparison configuration. After modification, click Create Now.
5. If you need to start the comparison immediately, click Start Comparison to initiate the pre-check and comparison task. If you want to start the comparison task later, see Starting a Comparison Task.

Terminating a Comparison Task

You can terminate a comparison task with the status of Executing or To Be Executed.
1. Log in to the DMC console.
2. In the left sidebar, select Advanced Development > Structure Comparison.
3. In the Operations column corresponding to the comparison task to be terminated, click More > Terminate.
Additionally, you can click View in the Operation column corresponding to the comparison task or click the task ID, and click Terminate on the comparison task details page.
4. In the pop-up window, click OK.

Deleting a Comparison Task

You can delete a comparison task with the status of To Be Started, Checking, Check Completed, Terminated, Execution Failed, and Completed.
1. Log in to the DMC console.
2. In the left sidebar, select Advanced Development > Structure Comparison.
3. In the Operation column corresponding to the comparison task to be deleted, click More > Delete.
4. In the pop-up window, click OK.

Downloading a Comparison Task List

1. Log in to the DMC console.
2. In the left sidebar, select Advanced Development > Structure Comparison.
3. Click

above the comparison task list to download a file in .csv format.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback