Help Center> Data Admin Service> User Guide> MySQL> Table Structure Comparison and Synchronization
Updated on 2023-12-13 GMT+08:00

Table Structure Comparison and Synchronization

This section describes how to check the structure difference by comparing and synchronizing table structures when you perform a migration or verification.

Prerequisites

To create a table structure comparison and synchronization task, you need to toggle on Save SQL first so that DAS can store your data. If you do not toggle on Save SQL, you cannot create table structure comparison and synchronization tasks.
Figure 1 Enabling the function of saving SQL statements

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner, and under Databases, click Data Admin Service.
  4. In the navigation pane on the left, choose Development Tool.

    You can also click Go to Development Tool on the overview page.

  5. Locate the DB instance that you want to log in to and click Log In in the Operation column.
  6. On the top menu bar, choose Structure Management > Table Structure Comparison and Synchronization.
  7. On the displayed page, click Create Task.
  8. On the Create page, configure required parameters and click Next.

    Figure 2 Creating a task
    Table 1 Parameter description

    Parameter

    Description

    Source Instance

    The DB instance that you have logged in to by default.

    Source Database

    Select a source database.

    Target Instance

    Select Current instance or Another instance.

    Target Database

    Select a target database to be compared with.

    Error Tolerance

    Configuring this parameter is recommended.

    After this parameter is configured, if a comparison or synchronization error occurs during task execution, the system ignores the error and continues the execution.

    Sync Type

    • Global: synchronizes all tables with the same name from the source database to the target one.
    • Specified: synchronizes specific tables with the same name from the source database to the target one.
    • One-to-one: allows you to specify a source table and target table for synchronization. The two tables can have different names.
    • One-to-more: synchronizes the structure of a table in the source database to multiple tables in the target database. This option is usually selected when you want to change table structures during database and table sharding.

  9. Click Next to go to the Compare page, check task information and comparison items, and click Compare.

    You can also select the items you want to skip and click Skip to cancel the comparison.

  10. View comparison progress.

    In the comparison item list, click View Logs in the Operation column to obtain comparison details. You can also click Download DDL as needed.

    Figure 3 Viewing comparison progress

  11. After comparison is complete, click Next. On the Synchronize page, view basic information about this comparison task, such as the source instance, source database, target instance, target database, and synchronization type, and in the synchronization item list, specify the items to be synchronized.

    Skip synchronization items that may cause high risks and then click Synchronize.

    Figure 4 Synchronizing data

  12. After synchronization is complete, click View Logs in the Operation column to obtain comparison details.

    You can download DDL as required.