This topic describes how to use Data Transmission Service (DTS) to update the starting values of sequences in the destination database of a data synchronization or migration instance.
Background information
A sequence is a special database object that is used to generate a set of unique ascending or descending numbers that are used as primary key values in tables. To avoid primary key conflicts caused by sequence changes after data is synchronized or migrated to the destination database, you can use the sequence value adjustment feature. This feature allows you to obtain the current value of a sequence in the source database, add an offset to the current value, and use the adjusted value as the starting value of the corresponding sequence in the destination database.
Assume that you specify an offset of 10000. If the current value of a sequence in the source database is 12345, DTS updates the starting value of the corresponding sequence in the destination database to 22345.
Supported scenarios
The PostgreSQL in the following table indicates an ApsaraDB RDS for PostgreSQL instance or a self-managed PostgreSQL database.
Source database | Destination database | References |
PostgreSQL | PostgreSQL, PolarDB (Compatible with Oracle), or PolarDB for PostgreSQL | |
PolarDB for PostgreSQL | PostgreSQL or PolarDB for PostgreSQL | |
PolarDB (Compatible with Oracle) | PolarDB (Compatible with Oracle) | |
Oracle | PolarDB (Compatible with Oracle) |
Prerequisites
The data synchronization or migration instance meets the following requirements:
The instance involves incremental data synchronization or migration.
The instance is in the Incremental Data Migration or Incremental Data Synchronization phase.
The Status of the instance is Running or Paused.
Usage notes
This feature is not supported for two-way synchronization instances.
By default, DTS updates the starting value of a sequence in the destination database based on the current value of a sequence with the same name in the source database. You cannot use this feature to update the starting value of a specified sequence in the destination database.
If incremental data is written to the source database after the starting values of sequences in the destination database are updated, the updated sequence values may not meet your expectations.
Procedure
Use one of the following methods to go to the Data Synchronization or Data Migration page and select the region in which your DTS instance resides.
DTS console
Log on to the DTS console.
In the left-side navigation pane, click Data Synchronization or Data Migration.
In the top navigation bar, select the region in which your DTS instance resides.
DMS console
NoteThe actual operations may vary based on the mode and layout of the Data Management (DMS) console. For more information, see Simple mode and Customize the layout and style of the DMS console.
Log on to the DMS console.
In the top navigation bar, choose or .
From the drop-down list to the right of Data Synchronization Tasks or Data Migration Tasks, select the region in which your DTS instance resides.
Find your DTS instance and click the instance ID.
Update the starting values of sequences in the destination database.
On the Task Management page, click Incremental Write.
On the Basic Information tab, click Synchronize Sequence.
In the dialog box that appears, specify the Sequence Offset parameter.
In the lower part of the dialog box, click Synchronize.
View the result.
After the update is complete, the Synchronized message appears and the sequence values before and after the update are displayed.
Click Close.