Manage schema versions

更新时间:
复制 MD 格式

After you change the schema of a database in Data Management (DMS), DMS saves the latest schema to a version list. You can use the list to download, compare, and restore historical schema versions.

Background

Schema versioning operates at the database level, and each version captures the schema of all tables in the database. A new version is automatically created whenever the schema of any table is modified. The following operations in DMS create a new schema version:

Note
  • If a schema change occurs outside of DMS, you can synchronize the metadata in DMS to capture and save the latest schema. For more information, see synchronize a data dictionary.

  • For instances in the Security Collaboration control mode, you can also synchronize metadata by clicking the 同步元数据按钮 icon in SQLConsole.

Prerequisites

  • You have query permission for the target table or database.

  • Your database is one of the following types:

    • MySQL-compatible: ApsaraDB RDS for MySQL, PolarDB for MySQL, PolarDB-X, and OceanBase databases in MySQL mode.

    • PostgreSQL-compatible: ApsaraDB RDS for PostgreSQL, PolarDB for PostgreSQL, and AnalyticDB for PostgreSQL.

    • PolarDB for PostgreSQL (Compatible with Oracle).

    • SQL Server.

    • MariaDB.

    • Oracle.

Limitations

  • The number of schema versions that can be retained varies by control mode:

    • Flexible Management: 3

    • Stable Change: 20

    • Security Collaboration: Unlimited

  • Schema versioning is not supported for the following types of databases:

    • Databases with more than 1,024 tables.

    • System databases, such as the information_schema or sys database in MySQL.

Manage schema versions

  1. Log in to DMS 5.0.

  2. Go to the Version Management page.

    Method 1: From Database Instances

    In the Database Instances section, find your target database, right-click the database name, and select Version Management.

    Method 2: From SQLConsole

    Go to SQLConsole and click the Version Management image icon in the upper-right corner.

    Method 3: From the Instances page

    This method is available only to administrators and DBAs.

    1. Move the pointer over the 2023-01-28_15-57-17.png icon in the upper-left corner of the DMS console and choose All Features > Data Assets > Instances.

      Note

      If you use the DMS console in normal mode, choose Data Assets > Instances in the top navigation bar.

    2. On the Database List tab, find your target database.

    3. In the Actions column, choose More > Version Management.

  3. On the Database version list page, find the target version and perform one of the following operations:

    • Click Change Details to view the SQL script for the schema change.

    • Click Rollback to revert the schema to the previous version.

    • Select two versions and click Version Comparison to compare their schemas.