All Products
Search
Document Center

PolarDB:Migrate data between PolarDB for PostgreSQL (Compatible with Oracle) clusters

Last Updated:Mar 28, 2026

Use Data Transmission Service (DTS) to migrate data from a PolarDB for PostgreSQL (Compatible with Oracle) 1.0 cluster to a 2.0 cluster with minimal downtime.

Choose a migration approach

DTS supports two approaches. Pick based on whether your workload can tolerate downtime.

Full migration onlyFull + incremental migration
DowntimeRequired during migrationMinimal — cut over after data is in sync
Best forNon-critical databases that can be taken offlineProduction databases that must stay online
WAL log retentionNot requiredAt least 7 days (source cluster)
BillingFreeCharged for the incremental phase

For production workloads, use full + incremental migration. This lets you cut over at a time of your choosing after data is fully in sync.

Prerequisites

Before you begin, ensure that you have:

Validate compatibility before migrating

Run a migration evaluation before starting the actual migration. This checks whether objects in your 1.0 cluster are compatible with 2.0 so you can fix issues in advance.

The evaluation does not affect running workloads.

Supported regions: China (Hangzhou), China (Shanghai), China (Shenzhen), China (Beijing), China (Zhangjiakou), China (Ulanqab), China (Chengdu), China (Hong Kong), Japan (Tokyo), Singapore, Indonesia (Jakarta), US (Silicon Valley), and US (Virginia).

Create an evaluation task

  1. Log on to the PolarDB console.

  2. In the upper-left corner, select the region where the source cluster is deployed.

  3. Open the evaluation dialog using one of these methods:

    • From the Clusters page: click Migration/Upgrade Evaluation in the upper-left corner. f741374229beacceee41de1406e3146b

    • From the Migration/Upgrade page: click Migration/Upgrade Evaluation in the upper-left corner. bc27346fe35a0fce09344544b84d85d8

  4. In the Migration /Upgrade Evaluation dialog box, configure the parameters and click Next.

    ParameterValue
    Creation MethodUpgrade from PolarDB
    Source PolarDB VersionOracle 1.0
    Source PolarDB ClusterSelect the source cluster
    Destination Database EngineOracle 2.0
    Database NameSelect the source database
  5. Review the compatibility results.

    • Overview — shows a summary of compatible and incompatible objects.3a515ca73a87b7c94447c2b31be9925d

    • Details — lists specific incompatible objects.dcda2a6170011b2215a7ccc37921cf6c

    Focus on incompatible objects in the results:

    • Oracle native objects can be ignored.

    • Objects involved in SQL statements must be adapted at the business side. If you cannot adapt them, contact Alibaba Cloud support.

Iterate until evaluation passes

After fixing incompatible objects, create a new evaluation task to confirm the issues are resolved. Repeat until all objects are compatible.

To view existing evaluation tasks, go to the Migration/Evaluation page.

Evaluation tasks are retained for seven days. Create a new task if yours has expired.

Limitations

Source database limitations

During schema synchronization, DTS synchronizes foreign keys from the source database to the destination database. During full data synchronization and incremental data synchronization, DTS temporarily disables constraint checks and cascade operations on foreign keys at the session level. If cascade updates or deletions run on the source database during this time, data inconsistency may occur.
  • Tables must have PRIMARY KEY or UNIQUE constraints with all fields unique. Otherwise, the destination database may contain duplicate records.

  • When migrating selected tables with object renaming (such as renaming tables or columns), a single migration task supports up to 1,000 tables. To migrate more than 1,000 tables, create multiple tasks or migrate the entire database instead.

  • For incremental data migration:

    • Write-ahead logging (WAL) must be enabled on the source cluster.

    • WAL log retention must be more than 24 hours for incremental-only migration, or at least 7 days for full + incremental migration. If WAL logs are unavailable, the task may fail or data loss may occur. After full migration completes, you can reduce the retention to more than 24 hours.

    • If you need to perform a primary/secondary switchover on the source cluster during migration, enable the Logical Replication Slot Failover feature first. For more information, see Logical replication slot failover.

  • During schema migration and full data migration, do not execute DDL statements. Doing so will fail the migration task.

  • For full-only migration, do not write to the source database during migration. Data written after migration starts will not appear in the destination. To avoid this, use full + incremental migration instead.

  • If the source database has long-running transactions with an incremental migration task active, uncommitted WAL data may accumulate and cause disk space issues.

Other limitations

  • Each migration task covers a single source database. Create separate tasks for multiple databases.

  • For incremental migration with schema-level objects: after creating a new table or renaming a table in a schema, run the following statement before writing data to that table:

    ALTER TABLE schema.table REPLICA IDENTITY FULL;

    Replace schema and table with your schema name and table name.

  • DTS creates a table named dts_postgres_heartbeat in the source database to track latency. The following figure shows the table structure.

    表结构

  • DTS creates a replication slot prefixed with dts_sync_ on the source database to capture incremental logs from the last 15 minutes.

    - After the DTS instance is released, the replication slot is deleted automatically. If you change the source database password or remove DTS from the IP address whitelist, the replication slot cannot be deleted automatically — you must delete it manually to prevent accumulation and cluster unavailability. - If the migration task is released or fails, DTS clears the replication slot automatically. If a primary/secondary switchover occurs on the source cluster, log on to the secondary instance and clear the replication slot manually.
  • Migrate data during off-peak hours. Full data migration reads from the source and writes to the destination concurrently, which increases load on both databases.

  • After full data migration, the destination tablespace is larger than the source due to fragmentation from concurrent INSERT operations.

  • DTS uses ROUND(COLUMN, PRECISION) to retrieve values from FLOAT and DOUBLE columns. Default precision: FLOAT = 38 digits, DOUBLE = 308 digits. Verify these settings meet your requirements.

  • DTS retries failed tasks for up to 7 days. Before switching workloads to the destination, stop or release any failed tasks — or revoke DTS write permissions using REVOKE — to prevent stale source data from overwriting the destination after a retry.

  • DTS does not validate sequence metadata. Check sequence validity manually.

  • After cutover, sequences do not automatically continue from the maximum value in the source database. Query and reset them before switching workloads. See Reset sequences after cutover.

Billing

Migration typeCost
Schema migration + full data migrationFree
Incremental data migrationCharged. For more information, see Billing overview.

Migration types and supported SQL

Migration types

TypeWhat it does
Schema migrationMigrates object schemas to the destination: tables, views, synonyms, triggers, stored procedures, stored functions, packages, and user-defined types. Triggers are not supported in this scenario — delete source triggers before migrating to avoid data inconsistency. For more information, see Configure a data synchronization or migration task for a source database that contains a trigger.
Full data migrationCopies all historical data from the source to the destination. Do not perform DDL operations on objects during this phase.
Incremental data migrationReads WAL log files from the source and continuously applies changes to the destination. Enables minimal-downtime migration.

SQL statements supported in incremental migration

DML: INSERT, UPDATE, DELETE

DDL (requires a privileged account on the source):

  • CREATE TABLE, DROP TABLE

  • ALTER TABLE: RENAME TABLE, ADD COLUMN, ADD COLUMN DEFAULT, ALTER COLUMN TYPE, DROP COLUMN, ADD CONSTRAINT, ADD CONSTRAINT CHECK, ALTER COLUMN DROP DEFAULT

  • TRUNCATE TABLE (source cluster version 1.0 or later)

  • CREATE INDEX ON TABLE

DDL not supported:

Important
  • CASCADE and RESTRICT modifiers on DDL statements are not synchronized.

  • DDL statements from sessions that run SET session_replication_role = replica are not synchronized.

  • If a commit contains both DML and DDL statements, the DDL is not synchronized.

  • If multiple statements committed at the same time include DDL for objects outside the synchronized scope, those DDL statements are not synchronized.

  • Data of the BIT type cannot be synchronized in incremental mode.

  • For tasks created before September 9, 2022, create a trigger and function in the source database to capture DDL before configuring the task. For more information, see Use triggers and functions to implement incremental DDL migration for PostgreSQL databases.

Create a migration task

Step 1: Open the Data Migration page

Use one of the following methods:

From the DTS console:

  1. Log on to the DTS console.

  2. In the left-side navigation pane, click Data Migration.

  3. In the upper-left corner, select the region where the migration instance resides.

From the DMS console:

The actual steps may vary based on the DMS console mode and layout. For more information, see Simple mode and Customize the layout and style of the DMS console.
  1. Log on to the DMS console.

  2. In the top navigation bar, go to Data + AI > DTS (DTS) > Data Migration.

  3. From the drop-down list next to Data Migration Tasks, select the region where the migration instance resides.

Step 2: Configure source and destination databases

Click Create Task, then configure the source and destination.

Set Database Type to PolarDB for PostgreSQL (Compatible with Oracle) for both source and destination.
Warning

Adding DTS CIDR blocks to your database IP address whitelist or ECS security group rules introduces security risks. Before proceeding, take preventive measures including: strengthening username and password security, limiting exposed ports, authenticating API calls, and regularly auditing whitelist rules. Alternatively, connect the database to DTS using Express Connect, VPN Gateway, or Smart Access Gateway.

Task settings:

ParameterDescription
Task NameAssign a descriptive name. Names do not need to be unique.

Source database (PolarDB for PostgreSQL (Compatible with Oracle) 1.0):

ParameterDescription
Select Existing ConnectionSelect an existing connection to auto-populate parameters, or configure manually.
Database TypePolarDB for PostgreSQL (Compatible with Oracle)
Access MethodAlibaba Cloud Instance
Instance RegionRegion of the source cluster
Replicate Data Across Alibaba Cloud AccountsSelect No for same-account migration
Instance IDID of the source cluster
Database NameName of the source database
Database AccountPrivileged account of the source cluster
Database PasswordPassword for the database account

Destination database (PolarDB for PostgreSQL (Compatible with Oracle) 2.0):

ParameterDescription
Select Existing ConnectionSelect an existing connection to auto-populate parameters, or configure manually.
Database TypePolarDB for PostgreSQL (Compatible with Oracle)
Access MethodAlibaba Cloud Instance
Instance RegionRegion of the destination cluster
Instance IDID of the destination cluster
Database NameName of the destination database
Database AccountDatabase owner account of the destination cluster. For more information, see Create a database account.
Database PasswordPassword for the database account

Click Test Connectivity and Proceed. DTS adds its CIDR blocks to the destination cluster's whitelist.

Step 3: Select objects and configure synchronization settings

All namespaces in the source database are listed. Select the namespaces you want to migrate.
ParameterDescription
Synchronization TypeSelect Schema Synchronization, Full Data Synchronization, and Incremental Data Synchronization. All three are required.
Synchronization TopologyOne-way synchronization: data flows from source to destination only. Two-way synchronization: data also flows from destination to source (incremental only, DDL not supported in reverse).
Processing Mode in Existed Target TablePrecheck and Report Errors: fails precheck if destination has tables with identical names. Use object name mapping to resolve conflicts. For more information, see Map object names. Ignore Errors and Proceed: skips the check. During full sync, existing destination records are kept; during incremental sync, source records overwrite destination records. Schema mismatches may cause partial sync or task failure.
Capitalization of Object Names in Destination InstanceControls capitalization of database, table, and column names. Default: DTS default policy. For more information, see Specify the capitalization of object names in the destination instance.
Source ObjectsSelect objects and click 向右 to add them to Selected Objects. Select columns, tables, or databases. If you select tables or columns, views, triggers, and stored procedures are not migrated.
Selected ObjectsRight-click an object to rename it or filter rows with a WHERE condition. Click Batch Edit to rename multiple objects at once. For more information, see Map object names and Use SQL conditions to filter data.

Step 4: Configure advanced settings

Click Next: Advanced Settings.

ParameterDescription
Dedicated Cluster for Task SchedulingRun the task on a DTS dedicated cluster for exclusive resources and better stability. For more information, see What is a DTS dedicated cluster.
Specify the retry time range for failed connectionsHow long DTS retries after a connection failure. Range: 10–1,440 minutes. Default: 720 minutes. Set to more than 30 minutes. When multiple tasks share the same source or destination, the shortest retry time takes precedence. DTS instance charges apply while retrying.
Retry Time for Other IssuesHow long DTS retries after DDL or DML failures. Range: 1–1,440 minutes. Default: 10 minutes. Set to more than 10 minutes. Must be smaller than the connection retry time.
Enable Throttling for Full Data MigrationLimits concurrent reads and writes during full migration to reduce load on source and destination databases.
Enable Throttling for Incremental Data MigrationLimits migration rate during incremental migration to reduce write pressure.
Environment TagLabels the task by environment (production, staging, etc.). Does not affect task behavior.
Configure ETLApplies extract, transform, and load (ETL) processing to migrated data. For more information, see What is ETL and Configure ETL in a data migration or data synchronization task.
Monitoring and AlertingSends alerts if the task fails or latency exceeds a threshold. Select Yes to configure alert contacts and thresholds. For more information, see Configure monitoring and alerting.

Step 5: Configure data verification

Click Next Step: Data Verification.

ParameterDescription
Data Verification ModeFull Data Verification: compares all data between source and destination. Requires configuring verification objects. For more information, see Configure the data verification feature for a data synchronization or migration task in DTS. Incremental Data Verification: verifies incrementally migrated data (selected by default). Schema Verification: verifies schemas of selected objects.

Step 6: Run the precheck

Click Next: Save Task Settings and Precheck.

  • To preview the corresponding API parameters, hover over the button and click Preview OpenAPI parameters.

DTS runs a precheck before starting migration.

  • If an item fails, click View Details to see the cause, fix the issue, and click Precheck Again.

  • If an alert is generated for an item you can safely ignore, click Confirm Alert Details, then click Ignore in the dialog box, then click Precheck Again.

Ignoring alert items may cause data inconsistency or expose your business to risks.

Step 7: Purchase the DTS instance

After the precheck reaches 100%, click Next: Purchase Instance.

ParameterDescription
Billing MethodSubscription: pay upfront for 1–9 months, 1 year, 2 years, 3 years, or 5 years. More cost-effective for long-term use. Pay-as-you-go: charged hourly. Suitable for short-term use.
Resource GroupThe resource group for the instance. Default: default resource group. For more information, see What is Resource Management?.
Instance ClassDetermines migration performance. Select based on your data volume and latency requirements. For more information, see Specifications of data synchronization instances.
DurationSubscription duration (displayed only for the subscription billing method).

Read and accept the Data Transmission Service (Pay-as-you-go) Service Terms, then click Buy and Start.

Track task progress in the task list.

How the migration runs

After the task starts, DTS automatically runs these phases in sequence. Monitor them on the Data Synchronization page of the DTS console.

  1. Precheck — Verifies network connectivity, permissions, and data format requirements.

    image.png

  2. Pre-processing — Creates triggers needed for subsequent data capture.

    image.png

  3. Incremental data collection — Starts capturing changes from the source before full migration begins, so no changes are missed.

    image.png

  4. Schema migration — Migrates schemas, sequences, functions, stored procedures, views, and indexes. If a schema migration step fails, use the schema revision feature to manually correct the SQL.

    image.png

  5. Full data migration — Copies all data for selected objects. Monitor data traffic and transfer speed on the Data Synchronization page.

    image.png

  6. Foreign key migration — Adds foreign key constraints to migrated tables to maintain referential integrity.

    image.png

  7. Incremental write — Applies changes captured since step 3 to the destination, then continuously syncs new changes.

    image.png

  8. Post-processing — Clears intermediate data and creates final indexes.

    image.png

  9. Full data verification — Compares all rows between source and destination. For example, 835,266 rows in the t1 table are compared and confirmed consistent.

    image.png

  10. Incremental data verification — Continuously compares incremental changes between source and destination.

    image.png

Cut over to the destination cluster

Test before cutting over

After migration reaches the incremental phase, add the destination cluster to a test environment and run comprehensive tests. Test for at least one week to confirm the destination cluster is stable before proceeding with cutover.

Reset sequences after cutover

After cutover, sequences do not automatically continue from the maximum value in the source database. Before switching workloads, query the maximum sequence values from the source and set them as the initial values in the destination.

Run the following statement on the source database to get the setval commands:

do language plpgsql $$
DECLARE
 nsp name;
 rel name;
 val int8;
BEGIN
 for nsp,rel in select nspname,relname from pg_class t2 , pg_namespace t3 where t2.relnamespace=t3.oid and t2.relkind='S' and relowner != 10
 loop
 execute format($_$select last_value from %I.%I$_$, nsp, rel) into val;
 raise notice '%',
 format($_$select setval('%I.%I'::regclass, %s);$_$, nsp, rel, val+1);
 end loop;
END;
$$;

The output lists setval() statements for each sequence. Run those statements on the destination database.

Perform the cutover

Plan a cutover window (for example, 10 hours). During this window:

  1. Stop all write workloads on the source database.

  2. Wait until the incremental migration latency reaches zero on the DTS console, which indicates that data replay on the destination database is complete.

  3. Update the database connection string in your application to point to the destination cluster.

  4. Restart the application and run basic functional tests.

  5. If tests pass, the destination cluster is live.

Keep the source database running until you confirm the destination cluster is completely stable. Release the source after you have verified all workloads are behaving as expected.

What's next

PolarDB for PostgreSQL (Compatible with Oracle) 2.0 available for commercial use