All Products
Search
Document Center

Data Management:Initialize empty databases

Last Updated:Jul 20, 2023

Data Management (Data Management (DMS)) provides the empty database initialization feature. You can use this feature to synchronize the schemas of the source database to an empty database that contains no table. This way, schemas can be synchronized between databases with ease. You can use this feature to synchronize the schemas of databases that are deployed across multiple regions and units.

Prerequisites

  • The source and destination databases are of the following types:
    • MySQL: ApsaraDB RDS for MySQL, PolarDB for MySQL, MyBase for MySQL, PolarDB for Xscale, AnalyticDB for MySQL V3.0, and MySQL databases from other sources
    • SQL Server: ApsaraDB RDS for SQL Server, MyBase for SQL Server, and SQL Server databases from other sources
    • PostgreSQL: ApsaraDB RDS for PostgreSQL, PolarDB for PostgreSQL, MyBase for PostgreSQL, AnalyticDB for PostgreSQL, and PostgreSQL databases from other sources
    • MariaDB: ApsaraDB for MariaDB and MariaDB databases from other sources
    • ApsaraDB for OceanBase in MySQL mode
    • PolarDB for PostgreSQL(Compatible with Oracle)
  • The security rule named Enable execution capability (if closed, other rules are invalid) is enabled for the destination database. For more information, see Enable execution capability.
    Note If this rule is disabled, the schema synchronization feature can only compare the schemas of two different databases but cannot execute SQL statements to synchronize the schemas.
  • The destination database is an empty database that contains no table.

    Note

    If the destination database contains tables, you can use the schema synchronization feature. For more information, see Synchronize schemas.

  • The query permissions on the source database are granted to your account. For more information, see View owned permissions.
  • The permissions to alter tables in the destination database are granted to your account. For more information, see View owned permissions.

Procedure

  1. Log on to the DMS console V5.0.
  2. In the top navigation bar, click Database Development. In the left-side navigation pane, choose Schema Change > Empty Database Initialization.
  3. On the Table/Database Synchronization Application page, set the parameters that are described in the following table.

    Parameter

    Description

    Source Database

    1. The name of the source database for empty database initialization.

    2. Optional:After you select the source database, specify the schema version number of the database. By default, the latest schema is used. For more information about the schema version number, see Manage schema versions.

    Target Database

    1. The name of the destination database for empty database initialization.

    2. Optional:Manage schema versions

    Initialized Table

    The one or more tables that you want to use for empty database initialization. Valid values:

    • Partial Tables: Only tables that you select are used for empty database initialization.

    • All Tables: All tables in the source database are used for empty database initialization.

    Whether to Ignore Error

    Specifies whether to skip an error that occurs when an SQL statement is being executed. Valid values:

    • Not Ignore: If an error occurs in executing an SQL statement, DMS stops executing the current and subsequent SQL statements.

    • Ignore: If an error occurs in executing an SQL statement, DMS skips the current SQL statement and continues to execute subsequent SQL statements until all remaining statements are executed.

  4. Click Submit.
    DMS starts to analyze the schemas.
    Note If the schemas are changed during schema analysis, click Re-analyze in the Schema Analysis step.
  5. Click Submit for Approval and wait for approval.
  6. Click Submit and Synchronize to Target Database.
  7. Check the SQL statements to be executed and click Confirm Synchronization.
    After you click Confirm Synchronization, DMS starts to execute the SQL statements to synchronize schemas. You can click Details to view the operations logs that contain detailed information such as the SQL statements, execution duration, and scheduling details.