DEV Community

Yana Ihnatchyck
Yana Ihnatchyck

Posted on

How to Migrate Data from Oracle to PostgreSQL

Oracle has been the default enterprise database for decades, but licensing costs, audit overhead, and vendor lock-in have pushed more engineering teams to look at alternatives. PostgreSQL has become the go-to replacement – mature, actively developed, and capable of handling enterprise workloads without the licensing bill. Once a team has settled on PostgreSQL as the target, the next question is purely practical: how do you actually move the data, and how do you do it without losing anything or breaking the systems that depend on it?

This article focuses specifically on that piece – how to migrate data from Oracle to PostgreSQL safely and predictably. It assumes the schema and target database design are already settled, and walks through the data movement itself: what to check beforehand, how to handle the transfer, and where developers typically run into trouble.

Know what you're moving before you move it

Before transferring a single row, a clear picture of the dataset matters. Table sizes vary enormously across a typical Oracle database, and a handful of large tables usually account for most of the total volume. Identifying those early matters, since they're the ones that will dictate how long the migration takes and whether batching or parallelizing the transfer makes sense.

Data types deserve careful attention. Oracle's NUMBER, VARCHAR2, and DATE types don't map one-to-one onto PostgreSQL equivalents – DATE in Oracle includes a time component, for instance, which trips up developers who map it directly to a PostgreSQL date field and lose precision. When this goes wrong, the data still transfers, but it transfers incorrectly, which is often worse than a failed migration because the problem doesn't surface until much later.

Encoding is worth checking too. Older Oracle databases sometimes use character sets other than UTF-8, and a mismatch during transfer can silently corrupt text data, especially anything with non-ASCII characters. Confirming source and target encoding before the transfer starts saves a lot of trouble later.

Finally, there's a decision to make about whether data moves in one pass or incrementally. A one-time cutover works for smaller datasets or systems that can tolerate downtime. For systems that need to stay available, an incremental approach – moving historical data first, then syncing recent changes closer to cutover – reduces the risk window significantly.

Tools: why purpose-built beats generic

It's possible to move data with hand-written export and import scripts, but for anything beyond a small dataset, this becomes slow and error-prone fast. Generic ETL tools can technically move rows between systems, but they aren't built with Oracle's and PostgreSQL's specific type systems and quirks in mind, which means more manual mapping and more opportunities for silent data errors.

Ispirer Data Migrator is built specifically for Oracle-to-PostgreSQL data transfer, which lets it handle the type mapping and encoding considerations described above automatically, instead of leaving someone to script around them. When schema conversion and PL/SQL business logic also need to move alongside the data, the broader toolset covers that ground — it's possible to migrate oracle database to postgresql with the Ispirer Toolkit, with Data Migrator handling the data transfer piece specifically. 

A few advantages stand out in the data migration itself:

  • Read-only connection to the source database – the tool never writes back to Oracle, which limits exposure risk during migration
  • No middleware required – deployment happens on the PostgreSQL side, with no intermediate software layer to manage or secure
  • Change Data Capture (CDC) support, including CDC without requiring access to transaction or REDO logs
  • Automated fault tolerance, so an interrupted migration resumes rather than restarting from scratch
  • Adjustable impact on the source system via speed throttling, useful for migrating data without disrupting production load
  • Support for the full range of PostgreSQL data types, from standard numeric and text types to JSON and BLOBs

For developers that want to migrate data from Oracle to PostgreSQL without building and maintaining custom transfer scripts, this kind of dedicated, direction-specific tooling is generally a faster and safer path than assembling something in-house.

The first run is worth treating as a test rather than the final migration – running it against a copy of production data and checking the output carefully before the real transfer is scheduled.

The data migration process, step by step

With the dataset assessed and tooling chosen, the actual transfer breaks down into several stages:

  1. Target database schema creation. Before any data moves, the schema is prepared on the PostgreSQL side – tables are defined in the target system, ready to receive the incoming data.
  2. Migration tool initialization. The migration solution is installed and deployed on the PostgreSQL server, connection parameters are configured, system functionality is validated, and the first migration phase is launched.
  3. Tracking migration progress. As the first phase runs, progress is monitored across all tables to ensure the transfer is proceeding as expected and to catch any issues early.
  4. Completing the first migration phase and continuing replication. Once the initial load finishes, subsequent migration phases begin. Replication lag is monitored continuously, and additional phases are launched until the lag between source and target reaches a minimum.
  5. Cutover preparation. When replication lag is minimal, the source application is suspended and zero latency is confirmed ensuring no new changes are coming in before the final switch.
  6. Enabling constraints and triggers. With data fully replicated, database constraints and triggers on the target are activated, bringing the PostgreSQL database into its fully operational state.
  7. Target application activation. The target application is switched on and the migration is complete.

Common pitfalls

A few issues come up often enough to call out directly.

Precision loss

Numeric and date fields are particularly vulnerable when type mapping isn't handled carefully. The data transfers, and the values look correct at a glance, but they're subtly wrong – a truncated decimal, a dropped time component – and the error often isn't noticed until well after cutover.

Encoding mismatches

Older Oracle databases sometimes use character sets other than UTF-8, and a mismatch during transfer can corrupt text silently, particularly anything with non-ASCII characters. This is one of the easier problems to prevent and one of the more painful ones to fix after the fact.

Underestimating large tables

A table that looks manageable by row count can still take hours to transfer if it's wide or has large BLOB/CLOB columns. Timing tests run against production-scale data, not a small sample, give a much more honest picture of how long the real migration will take.

The single best mitigation across all of these is validation discipline. The transfer isn't done once the load script finishes, confirming the data matches the source is what actually closes out the migration.

Wrapping up

Knowing how to migrate data from Oracle to PostgreSQL comes down to three things: understanding what you're moving, choosing tooling built for the job rather than improvised scripts, and validating thoroughly before cutover. The technical pieces – type mapping, encoding, large table handling – are well understood and solvable, but they require attention rather than assumptions.

Developers that treat data migration as a planned, validated process rather than a one-time export-and-import script are the ones that move from Oracle to PostgreSQL without a story about the data that didn't quite make it across.


Enter fullscreen mode Exit fullscreen mode

Top comments (0)