Skip to content
← Blog
oracle to postgresqldatabase migrationpostgresqloraclechange data capturecutover

Oracle to PostgreSQL Migration, Step by Step: Schema, Data Sync and a Minimal-Downtime Cutover

Brice Ayres /

Short answer

An Oracle to PostgreSQL migration runs in nine steps: inventory and assess, design the target and data type mapping, convert schema and PL/SQL, change the application, full load plus change data capture (AWS DMS or Debezium with LogMiner), validate, test performance, rehearse the cutover at least twice, then cut over with reverse replication ready for rollback. Projects slip most on PL/SQL packages, data type edge cases such as Oracle DATE and empty strings, and skipped rehearsals.

Dark war-room desk at night with two monitors showing grey database schema diagrams and an amber progress bar, a coffee mug and a printed checklist, and server racks glowing behind a glass wall

An Oracle to PostgreSQL migration is a sequence of nine steps, and each one has a gate you shouldn’t skip: assess, design the target, convert schema and code, change the application, load and sync with CDC, validate, test performance, rehearse, then cut over with a rollback path ready. The tools are good now. Projects slip on the things tools don’t decide: PL/SQL packages with business logic, data-type edge cases, application SQL nobody inventoried, and cutovers that were never rehearsed end to end.

This is the step-by-step plan. We cover the money side in Oracle to Postgres migration cost and compare tools (Ora2Pg, AWS DMS Schema Conversion, AI agents) in choosing migration tools and a cutover you can roll back. This post ties those together into an order of work.

Step 1: What do we have, and what’s hard?

Gate: a written inventory and a complexity estimate everyone agrees with.

  • Schemas, objects and sizes: tables, indexes, partitions, LOBs, sequences, synonyms, database links, materialized views and scheduler jobs.
  • Code in the database: packages, procedures, functions and triggers, with line counts and the Oracle features they use.
  • Code outside the database: every application, report, ETL job and script that sends SQL to Oracle. This is the most often missed item. Search code repositories and capture SQL from Oracle’s own views during a busy period.
  • Assessment tooling: Ora2Pg scans an Oracle database and can produce a migration report with an effort estimate. AWS DMS Schema Conversion and other tools produce similar reports. Treat the estimate as a starting point. It counts objects; it can’t tell how risky the logic is.

Output: a list of what moves, what’s retired, and what’s hard. Usually that’s PL/SQL with heavy business logic, Oracle-specific features and the largest tables.

Step 2: How will the target look?

Gate: an approved data type map and target design.

Decide these before converting anything:

  • Where PostgreSQL runs: managed service or self-managed, version and extensions. Pick a current, supported major version.
  • Data types:
    • Oracle NUMBER without precision maps to numeric, which is exact but slower. Use integer, bigint or numeric(p,s) where the data allows.
    • Oracle DATE includes a time of day. Mapping it to PostgreSQL date silently drops the time. Usually it should be timestamp(0).
    • Oracle treats an empty string as NULL; PostgreSQL doesn’t. Queries and constraints that rely on that behavior will change results.
    • VARCHAR2 byte vs character semantics, CLOB to text, BLOB to bytea or external storage.
  • Schemas and naming: Oracle folds unquoted names to upper case; PostgreSQL folds to lower case. Decide early and keep it consistent.
  • Sequences and identity columns, and how values continue after cutover.

Step 3: How do we convert schema and PL/SQL?

Gate: the converted schema builds cleanly, and converted code passes tests written against Oracle’s behavior.

  • Run the automated conversion for tables, indexes, constraints and simple code.
  • Hand-convert what tools don’t. Typical items include packages with package state, autonomous transactions, CONNECT BY hierarchies (rewrite as recursive CTEs), old-style (+) outer joins, ROWNUM logic, DUAL, Oracle-specific built-in packages, and exception handling that depends on Oracle error codes.
  • Write tests from the Oracle side first: given these inputs, Oracle returns these outputs. Then run the same tests against PostgreSQL. AI tools can speed up conversion, but tests prove it.
  • Track every object in a conversion log with status: auto-converted, hand-converted, retired or blocked.

Step 4: What changes in the application?

Gate: the application runs its full test suite against PostgreSQL.

  • Swap drivers and connection settings, and review connection pooling.
  • Fix SQL dialect differences in application code and ORMs.
  • Transactions behave differently. In PostgreSQL, an error inside a transaction aborts the rest of it until rollback. Code that catches an error and keeps going in the same transaction needs savepoints or a redesign.
  • Check implicit conversions, date arithmetic, sort order and collation, and case sensitivity in comparisons.

Step 5: How do we load the data and keep it in sync?

Gate: the full load matches, and CDC lag stays near zero for a sustained period.

Use a full load followed by change data capture (CDC), so Oracle stays the live system while PostgreSQL catches up:

  • AWS DMS supports Oracle as a CDC source and has built-in validation.
  • Debezium’s Oracle connector reads changes with Oracle LogMiner by default, and can also use XStream (a commercial GoldenGate component) or OpenLogReplicator. Its docs give two warnings worth planning for. First, if the initial snapshot runs longer than the database’s UNDO_RETENTION (15 minutes by default), you can hit ORA-01555. Second, DDL on captured tables during a snapshot can force a restart. For large tables, consider a schema-only snapshot followed by incremental snapshots.
  • Enable supplemental logging on Oracle as the CDC tool requires, and size redo and archive log retention so CDC can’t fall behind the logs.
  • Load big tables in parallel and build indexes after the load.
  • Freeze schema changes on Oracle during the sync, or route them through a process that applies them to both sides.

Step 6: How do we prove the data is right?

Gate: reconciliation reports signed off by data owners.

  • Row counts per table, plus checksums or hash comparisons on key columns, run repeatedly during sync, not once.
  • Business reconciliations: totals by account, by month, by status, the numbers finance actually looks at.
  • Spot checks on edge cases such as nulls vs empty strings, time-of-day on dates, numeric precision and character encoding.

Step 7: Will it perform?

Gate: production-like load meets agreed response times.

  • Replay or simulate production workload against PostgreSQL with production-scale data.
  • Compare plans for the top queries by time. Expect some to need new indexes, rewritten SQL or updated statistics.
  • Tune memory, connections and autovacuum for the workload. Don’t carry Oracle settings across by analogy.

Step 8: Why rehearse the cutover?

Gate: at least two full rehearsals that finish inside the planned window.

Rehearse the real runbook with real people against a copy of production: stop writes, confirm zero lag, run final validation, fix sequences, switch connections, smoke test, start reverse replication. Time each step. Every rehearsal finds something, like a missing grant, a job that still points at Oracle, or a sequence off by one. That’s the point.

Step 9: How do we cut over with minimal downtime?

Gate: go/no-go decision against written criteria.

  1. Announce a short write freeze.
  2. Stop writes on Oracle and wait for CDC to reach zero lag.
  3. Run the final reconciliation.
  4. Set sequences past Oracle’s highest values.
  5. Switch application connections to PostgreSQL.
  6. Start reverse replication from PostgreSQL back to Oracle, so rollback means switching back, not restoring a backup.
  7. Watch errors, latency and reconciliations against rollback triggers you agreed in advance.

Downtime is the freeze-to-switch window, often minutes when rehearsed, not the whole migration. Our rollback planning section covers reverse replication in more detail, and migrating without a freeze covers the general dual-run pattern.

After cutover: when do we turn Oracle off?

Keep the rollback path for an agreed period, usually through at least one month-end or other peak, then stop reverse replication, archive what regulations require, and decommission Oracle. Confirm license end dates with procurement so you actually stop paying.

Where do Oracle to PostgreSQL projects slip?

  • PL/SQL packages that turn out to hold core business logic.
  • Application SQL outside the inventory.
  • DATE, empty-string and numeric-precision differences found late, in reconciliation.
  • CDC that can’t keep up during peak hours, or log retention that’s too short.
  • Skipping rehearsals because “the last test went fine.”

FAQ

How long does an Oracle to PostgreSQL migration take?

It depends on code in the database and the number of applications more than on data size. We break down the drivers in our cost and timeline post.

Can we migrate with zero downtime?

Near-zero is realistic with CDC and a rehearsed cutover. True zero usually needs application-level dual writes, which adds risk and work. Most teams accept a short, planned freeze.

Should we use AWS DMS or Debezium for CDC?

DMS is simpler if you’re landing in AWS and want a managed service. Debezium fits if you already run Kafka or want change events for other consumers too. Both need supplemental logging and careful log retention on Oracle.

Do we have to convert all PL/SQL to PL/pgSQL?

No. Some logic is better moved into the application or retired. Decide per package during assessment.

Want help with yours?

Our database migration work follows this sequence. We start with a scoping sprint that produces the inventory, the data type map and a plan. Then we do a fixed-scope, fixed-fee migration with a US-based team. Book a call to talk through your Oracle estate.

Have a project like this?

We do this work for a living.

A 30-minute scoping call with the engineers who would do the work.

Or email contact@axiointelligence.com and we’ll reply.

Keep reading