After you change the schema of a table in a database in Data Management (DMS), DMS adds the latest schema to the schema version list of the database. You can download and compare schema versions and restore an earlier schema version in the schema version list.

Prerequisites

You have permissions to query the data of the table or the database to which the table belongs. For more information, see View owned permissions.

Overview

Schema versions are defined based on a database and store the schema information of all the tables in the database. If the schema of a table in the database is changed, a new schema version is saved. For more information, see Save new schema versions.

If a database instance that has five databases is managed in Security Collaboration mode, each database can contain 50 schema versions. In other words, for a database instance that is managed in Security Collaboration mode, a maximum of 50 schema versions can be retained for each database in the instance.

Usage notes

  • The following database engines are supported:
    • MySQL series: native MySQL, ApsaraDB RDS for MySQL, PolarDB for MySQL, PolarDB-X, AnalyticDB for MySQL, and ApsaraDB OceanBase for MySQL
    • PostgreSQL series: native PostgreSQL, PolarDB for PostgreSQL, and AnalyticDB for PostgreSQL
    • PolarDB-O
    • SQL Server
    • MariaDB
  • The following content shows the maximum number of schema versions that can be retained for each database in database instances that are managed in different control modes:
    • Flexible Management: 3
    • Stable Change: 20
    • Security Collaboration: 50
  • You cannot manage schema versions for the following databases:
    • Databases that contain more than 1,024 tables
    • System databases such as the information_schema and system databases in a MySQL database instance

Manage schema versions

  1. Log on to the DMS console V5.0.
    Note To switch to the previous version of the DMS console, click the 5租户头像 icon in the lower-right corner of the page. For more information, see Switch to the previous version of the DMS console.
  2. In the top navigation bar, click SQL Console. The SQL Console tab appears.
    Note If you are using the previous version of the DMS console, skip Step 2 and Step 3.
  3. In the Please select the database first dialog box, enter a keyword to search for a database, select the database from the search results, and then click Confirm.
  4. In the left-side navigation pane of the DMS console, click the database instance in which the database that you want to manage resides, right-click the database, and then select Version management.
    Note You can also go to the Database version list page by using the following methods:
    • On the SQLConsole tab of the database that you want to manage, move the pointer over the 1 icon and select Version management.
    • On the Database List tab of the Instance page, find the database that you want to manage, move the pointer over More in the Actions column, and then select Version management. You can use this method to go to the Database version list tab only as a DMS administrator or a database administrator (DBA).
  5. On the Database version list tab, find the version number of the schema that you want to manage. You can perform the operations that are described in the following table.
    Operation Description
    View View the detailed information of the schema version.
    Preview script Preview the SQL script that is used to generate the schema version.
    Table structure comparison Synchronize the schema version to another database, or compare the schema version with a schema version in another database. For more information, see Synchronize schemas.
    Structural recovery Synchronize the schema version that you want to restore to an empty database. For more information, see Initialize empty databases.

Save new schema versions

New schema versions are saved when the following operations are performed in DMS:
Note
If the schema of a table in a database is changed in environments other than DMS, you can perform the following operations in DMS to synchronize the latest schema of the database:
  • If the instance in which the database resides is managed in Security Collaboration mode, click the Sync Metadata icon icon in the upper-right corner of the SQLConsole tab to synchronize the latest schema.
  • If the instance in which the database resides is managed in Flexible Management or Stable Change mode, click the Refresh icon icon in the upper-left corner of the SQLConsole tab to synchronize the latest schema.