Shadow table synchronization in Data Management (DMS) automatically creates shadow tables in a database based on the schema of source tables. Shadow tables mirror the structure of their source tables but are named with a configurable prefix or suffix, making them safe to use for end-to-end stress testing without affecting production data. DMS supports one-time and scheduled synchronization.
Prerequisites
Before you begin, ensure that you have:
A source database of one of the following types:
MySQL: ApsaraDB RDS for MySQL, PolarDB for MySQL, ApsaraDB MyBase for MySQL, PolarDB-X, AnalyticDB for MySQL V3.0, and MySQL databases from other sources
SQL Server: ApsaraDB RDS for SQL Server, ApsaraDB MyBase for SQL Server, and SQL Server databases from other sources
PostgreSQL: ApsaraDB RDS for PostgreSQL, PolarDB for PostgreSQL, ApsaraDB MyBase for PostgreSQL, AnalyticDB for PostgreSQL, and PostgreSQL databases from other sources
MariaDB: ApsaraDB RDS for MariaDB and MariaDB databases from other sources
ApsaraDB for OceanBase in MySQL mode
PolarDB for PostgreSQL (Compatible with Oracle)
Query and change permissions on the source database. See View owned permissions
The Enable execution capability security rule enabled for the database in which you want to create shadow tables. See Enable execution capability
Without the Enable execution capability security rule, DMS can compare schemas but cannot execute SQL statements to apply the changes.
Create shadow tables
Log on to the DMS console V5.0.
In the top navigation bar, choose Database Development > Schema Change > Shadow Table Synchronization.
In simple mode, hover over the icon in the upper-left corner and choose All Features > Database Development > Schema Change > Shadow Table Synchronization.
On the Table Sync Tickets page, configure the following parameters:
Parameter Description Source Database The database in which to create shadow tables. Your account must have query and change permissions on this database. See View owned permissions. Prefix / Suffix The prefix or suffix appended to each source table name to form the shadow table name. Format: <Prefix>+ source table name, or source table name +<Suffix>. Default:__test_prefix, producing names like__test_<source_table_name>.Synchronized Table The scope of tables to synchronize. Partial Tables: synchronize only the tables you select. All Tables: synchronize all tables in the database. Synchronization Policy When to run the synchronization. Synchronize Now: runs once immediately after you submit the ticket. Scheduled Synchronization: runs on a recurring schedule you define using a crontab expression. The minimum interval is 1 hour. The default schedule runs daily at 02:00. Whether to Ignore Error How DMS handles SQL execution errors. Not Ignore: stops execution when an error occurs. Ignore: skips the failed statement and continues executing remaining statements. Click Submit. DMS begins schema analysis, comparing the source table schemas to determine which SQL statements are needed. If schemas change during this step, click Re-analyze in the Schema Analysis step to refresh the analysis.
Click Submit for Approval and wait for the ticket to be approved. This step sends the ticket through your organization's approval workflow. DMS does not execute any SQL statements until the ticket is approved and you proceed to the next step.
Click Submit and Synchronize to Target Database.
Review the SQL statements to be executed, then click Confirm Synchronization. DMS executes the SQL statements to synchronize schemas. Click Details to view operation logs, including the SQL statements, execution duration, and scheduling details.
Crontab expressions
Use a crontab expression to schedule recurring synchronization. An expression is a space-separated string of six fields:
Second Minute Hour Day Month WeekField reference
| Field | Valid values | Special characters |
|---|---|---|
| Second | 0–59 | - * / |
| Minute | 0–59 | - * / |
| Hour | 0–23 | - * / |
| Day | 1–31 | - * ? / L W C |
| Month | 1–12 or JAN–DEC | - * / |
| Week | 1–7 or SUN–SAT (1 = Sunday, 2 = Monday, ..., 7 = Saturday) | - * ? / L C # |
Specify a value for either Day or Week, not both. Set the unused field to ?.
Special characters
| Character | Description | Example |
|---|---|---|
* | All values | * in Minutes runs every minute |
? | Any value (Day and Week only) | Placeholder for whichever of Day or Week you are not specifying |
- | Range | 5-20 in Minutes runs each minute from minute 5 to minute 20 |
/ | Start and interval | 5/20 in Minutes runs at minute 5, 25, and 45 |
, | List | 5,20 in Minutes runs at minute 5 and minute 20 |
L | Last day or weekday (Day and Week only) | 5L in Week runs on the last Thursday of the month |
W | Nearest weekday Mon–Fri (Day only) | 5W runs on the nearest weekday to the 5th of the month |
LW | Last weekday of the month | — |
# | Nth weekday in the month (Week only) | 4#2 runs on the Wednesday of the second week (4 = Wednesday, 2 = second week) |
Examples
| Expression | Schedule |
|---|---|
0 0 23 ? * 7,1 | 23:00 every Saturday (7) and Sunday (1) |
0 30 9 5,15,25 * ? | 09:30 on the 5th, 15th, and 25th of each month |
0 0 0 */2 * ? | 00:00 every two days |
13 13 15 20 * ? | 15:13:13 on the 20th of each month |