Migration guide · Tool walkthrough

How to migrate Oracle to PostgreSQL with Ora2Pg

A hands-on walkthrough of Ora2Pg, the free Oracle to PostgreSQL converter: install it, write the config file, size the job, export the schema, load the data and check the result.

45 minutes with an engineer: we review your workload and sketch the design.

  • Ora2Pg 25.0
  • GPL v3 or later
  • Oracle to PostgreSQL

Ora2Pg is a free Perl tool that connects to Oracle, reads its objects and writes SQL for PostgreSQL. To use it: install Perl, DBD::Oracle and Ora2Pg, set the connection in ora2pg.conf, run the SHOW_REPORT assessment, export the schema by object type, load the data with COPY, then run its TEST actions. It does a one-time copy and needs a change-capture tool to stay in sync (checked 5 Dec 2026).

Customers

  • Microsoft logo
  • Henry Schein logo
  • Enbridge logo
  • Gojek logo

Partners

  • Broadcom logo
  • Redis logo
  • VMware Tanzu logo
  • OSSeva logo

What is Ora2Pg and what does it do?

Ora2Pg is a free tool that scans an Oracle database and generates SQL scripts for PostgreSQL. It exports the structure or the data, and it can run an assessment that estimates how hard the migration is. It is a Perl script, so it runs on Linux, macOS and Windows (Ora2Pg docs, checked 5 Dec 2026).

The project is maintained by Gilles Darold and is licensed under the GNU General Public License, version 3 or later (license, checked 5 Dec 2026). The latest release on GitHub is v25.0, published 20 April 2025 (release notes, checked 5 Dec 2026).

What it is good at: converting tables, constraints, indexes, sequences, views, partitions, grants and, with manual review, PL/SQL. What it is not: a replication product. Its manual states that it has no feature for importing data once and then applying only the later changes (Ora2Pg manual, checked 5 Dec 2026). That one fact decides most of the planning below. The done-for-you version is the Oracle to PostgreSQL service page; this page is for running the tool yourself.

How do you install Ora2Pg?

Install Perl 5.10 or later, the Oracle Instant Client, the DBI module (version above 1.614) and DBD::Oracle, then build Ora2Pg with the standard Perl steps. DBD::Pg and the psql client are optional and only matter for how you load the output (installation docs, checked 5 Dec 2026).

PieceNeeded forNotes from the docs
Perl 5.10 or laterRunning Ora2PgStrawberry Perl on Windows.
Oracle Instant Client or a full Oracle clientReaching OracleORACLE_HOME must be set for DBD::Oracle to build and work.
DBI above 1.614 and DBD::OracleReading the Oracle databaseInstall from CPAN or your distribution's packages.
psql or DBD::PgLoading the output (files or direct)Optional: psql for files, DBD::Pg for a direct PostgreSQL DSN.

Source: Ora2Pg installation docs; checked 5 Dec 2026.

Build and test the connection
tar xjf ora2pg-x.x.tar.bz2 && cd ora2pg-x.x/
perl Makefile.PL
make && make install
# installs ora2pg into /usr/local/bin and ora2pg.conf into /etc/ora2pg/
ora2pg -t SHOW_VERSION -c config/ora2pg.conf

The manual's advice is to spend time on that last command: it prints the Oracle server version and most problems show up there, not later (Ora2Pg manual, checked 5 Dec 2026). The --project_base and --init_project options create a project tree, a generic config file and export_schema.sh and import_all.sh scripts.

45 minutes with an engineer: we review your workload and sketch the design, then price it.

What goes in the ora2pg.conf config file?

One file, ora2pg.conf, controls the whole migration. Each line is an upper-case directive, a tab and a value. The minimum is the Oracle connection (ORACLE_DSN, user and password), an optional SCHEMA, and a TYPE that says what to export. Command-line options override the file (configuration docs, checked 5 Dec 2026).

A minimal ora2pg.conf (values are placeholders)
ORACLE_DSN	dbi:Oracle:host=oradb.example.com;service_name=pdb1;port=1521
ORACLE_USER	migration_ro
ORACLE_PWD	********
SCHEMA	HR
TYPE	TABLE
OUTPUT	output.sql

Use a read-only Oracle account for the export; the docs say ORA2PG_USER and ORA2PG_PASSWD environment variables can replace the credentials in the file. If a run dies, the manual says it is most often out of memory and the first fix is a lower DATA_LIMIT (Ora2Pg manual, checked 5 Dec 2026).

How do you run the Ora2Pg assessment report?

Run ora2pg with the SHOW_REPORT type and the --estimate_cost flag. It lists every object type, flags what it cannot export, and totals a cost in migration units, each about five minutes of work for a PostgreSQL expert. It also gives a difficulty level from A to C and 1 to 5 (Ora2Pg manual, checked 5 Dec 2026).

osstend.yaml
ora2pg -t SHOW_REPORT --estimate_cost -c config/ora2pg.conf --dump_as_html > report.html
LevelWhat it means in the docs
AMight be run automatically.
BCode rewrite, cost up to a set limit in person-days.
CCode rewrite above that limit.
1 to 5Difficulty: 1 is no stored functions or triggers, 5 is functions or triggers needing rewrites.

Treat the cost figure as a ranking tool, not a quote: the manual itself calls the method a work in progress. It is best for deciding which database to migrate first and where the PL/SQL effort sits. It can also score a file of PL/SQL or SQL queries, which sizes the application's own SQL.

Which export types do you run, and in what order?

Ora2Pg runs one TYPE at a time. Export the structure first (TABLE, SEQUENCE, VIEW, PARTITION, TYPE), review and load it, then the code (FUNCTION, PROCEDURE, PACKAGE, TRIGGER), and the data last with COPY. The docs say several types need hand editing before they will load (Ora2Pg manual, checked 5 Dec 2026).

TYPEWhat it extractsPlan for
TABLETables with indexes, primary, unique, foreign and check constraints (the default)Load first, without indexes if the data is large
SEQUENCESequences and their last positionsRe-run at cutover so values are current
VIEW and MVIEWViews; materialized views as snapshot materialized viewsUpdatable views need INSTEAD OF triggers
FUNCTION, PROCEDURE, PACKAGECode, with basic PL/SQL to PL/pgSQL conversionAlways reviewed and tested by a person
TRIGGERTriggersSame review as code
GRANT, SYNONYM, DBLINKPrivileges; synonyms as views; links as foreign data wrappersDesign decisions, not straight copies
COPY and INSERTData as COPY or INSERT statementsCOPY is the normal choice for bulk
TEST, TEST_COUNT, TEST_VIEW, TEST_DATACompare Oracle and PostgreSQLRun after the load, before cutover

Source: Ora2Pg manual, TYPE directive; checked 5 Dec 2026.

A practical order is to export and load schema objects into an empty test PostgreSQL database, fix what fails, repeat until the load is clean, and only then move data.

How does Ora2Pg load the data, and how do you make it faster?

Set TYPE to COPY and Ora2Pg writes COPY statements you load with psql, or set PG_DSN and it loads directly. Speed comes from parallelism: JOBS for loading, ORACLE_COPIES to split each Oracle query, PARALLEL_TABLES for several tables at once, and dropping foreign keys and indexes until the end (Ora2Pg manual, checked 5 Dec 2026).

DirectiveWhat it doesCatch
JOBSNumber of processes sending data into PostgreSQLDisabled on Windows
ORACLE_COPIES and DEFINED_PKSplits each query by a key column across processesNeeds a usable primary or unique key
PARALLEL_TABLESTables extracted at the same time, one connection eachTurns ORACLE_COPIES off; total processes are PARALLEL_TABLES times JOBS
DATA_LIMITRows held in memory per chunk (default 10,000)Higher is faster but uses more memory
DEFER_FKEY or DROP_FKEYDelay or drop foreign keys during the loadDEFER_FKEY does not work with direct import

Source: Ora2Pg manual, configuration directives; checked 5 Dec 2026.

Index builds are often the slow tail: the LOAD type spreads a file of SQL, such as index definitions, over several PostgreSQL connections with -j. The --oracle_speed option measures how fast Oracle can send data without writing anything, which helps you forecast the run.

What can Ora2Pg not convert?

It does its best to convert automatically, but its own documentation says manual work remains: the PL/SQL it generates for functions, procedures, packages and triggers has to be reviewed. Some object types are skipped or changed in shape, and Oracle behaviours such as empty strings equalling NULL are not carried over by default (features page, checked 5 Dec 2026).

Skipped or reshaped objects.
The manual's sample report says clusters are not supported, cluster, domain, bitmap-join and index-organized indexes are not exported, reverse indexes are not exported, type bodies with member methods are not exported, and Oracle jobs are not exported (use cron). That sample comes from an old Oracle 10g database, so run the report on your own schema rather than trusting the list.
Empty strings.
Oracle treats an empty string as NULL and PostgreSQL does not. The NULL_EQUAL_EMPTY directive rewrites NULL tests with coalesce to mimic Oracle, and the docs say the better fix is to turn empty strings into NULL in the application.
Numbers.
NUMBER with a precision and scale is converted according to PG_NUMERIC_TYPE. The docs warn that setting it to 1 makes NUMBER(p,s) approximate real or float types, so money columns need numeric. DATA_TYPE overrides any single mapping.
Oracle-only SQL in the application.
Outer joins written with the (+) syntax, DECODE and similar need rewriting. The QUERY type helps.

How do you check the migrated data matches?

Ora2Pg ships its own checks. TEST compares objects and row counts between Oracle and PostgreSQL, TEST_COUNT compares row counts, and TEST_DATA compares actual rows through a foreign table. Data validation compares the first 10,000 rows per table by default and needs a primary or unique key (Ora2Pg manual, checked 5 Dec 2026).

One trap: validation sorts by the key on both sides, so if the PostgreSQL collation of that key is not C the sort order can differ from Oracle and the comparison fails. Set DATA_VALIDATION_ROWS to zero to compare every row, and add your own checks such as column sums.

How long does an Ora2Pg migration take?

There is no honest fixed figure. The assessment report gives an effort estimate in person-days from your schema, using five-minute units by default, and the data load time depends on volume, network and parallelism. Measure both on your own system before you promise a date (Ora2Pg manual, checked 5 Dec 2026).

Schema and code
read the SHOW_REPORT total and add time for the application's own SQL.
Data load
time one large table with a trial COPY, then scale by total volume.
Rehearsals
plan a full dry run against a copy, because index builds and constraint validation only show their real cost at full size.

Can Ora2Pg migrate Oracle with no downtime?

Not alone. Ora2Pg is a one-time copy, so writes made to Oracle during and after the load are not carried over. It can record the Oracle SCN for each table at export time with --cdc_ready, and a separate change-data-capture tool can start from those points (Ora2Pg manual, checked 5 Dec 2026).

The SCNs are written to a TABLES_SCN.log file, one table:SCN pair per line, for the tool to consume. The combination is Ora2Pg for schema, code and the initial copy, plus a log-based capture tool for the changes. The Ora2Pg docs also advertise a commercial Ora2Pg+ offer for zero-downtime replication, which is worth pricing against the open-source route. For how capture tools work, read change data capture explained, and for the tool side see managed Debezium. The full pattern, with cutover and fallback, is on the Oracle to PostgreSQL migration page.

When is Ora2Pg the right way to migrate, and when is it not?

Ora2Pg is the right starting point for almost any Oracle to PostgreSQL move, because it sizes the job for free. It is the wrong place to stop when the business cannot tolerate a long write outage or the PL/SQL estate is large.

Contact us if

  • You have a few schemas, a modest amount of PL/SQL and a maintenance window long enough for a bulk load.
  • You want a free, scriptable assessment before you decide whether to migrate at all.
Talk to an engineer

Not a fit if

  • The application cannot stop writing for the length of the load and you have no change-capture tool planned.
  • The report shows thousands of lines of PL/SQL, packages with heavy state or Oracle-only features such as clusters and member-method types.

If you would rather hand the move over, OSStend runs migrations to managed PostgreSQL with the design written and signed off first and the failover rehearsed before go-live. Price is quoted per design on the pricing page. Other engines are on the migration hub.

Questions about Ora2Pg

What is Ora2Pg used for?

Converting an Oracle database to PostgreSQL. It scans Oracle, exports the schema, code and data as SQL, and estimates the effort (Ora2Pg docs, checked 5 Dec 2026).

How do I do an Oracle to Postgres migration using Ora2Pg?

Install Ora2Pg and DBD::Oracle, fill in ora2pg.conf, run SHOW_REPORT, export and load the schema objects into a test database, fix what fails, then export data with COPY and run TEST and TEST_COUNT. Cut over once the checks pass (checked 5 Dec 2026).

How does Ora2Pg data migration work?

With TYPE COPY or INSERT, Ora2Pg reads rows from Oracle in chunks and writes statements to a file, or loads PostgreSQL directly if PG_DSN is set. Parallel options speed it up (Ora2Pg manual, checked 5 Dec 2026).

Talk to an engineer

Plan your Oracle move with an engineer

45 minutes with an engineer: the current setup is reviewed, the method is chosen and the cutover is sketched. Designs are written and signed off first, and a failover is rehearsed before go-live. Pricing is quoted per design.

  • A design sketch for your workload, not a plan menu
  • A zero-downtime cutover path for what you run today
  • A price for that design, after the review
See pricing →

Your request goes to Scott Sternloff, Senior Enterprise Architect. No newsletter sign-up.

Get a quoteTalk to an engineer
2Engines Optional
3Where should it run?
4What do you need?

Your request goes to Scott Sternloff, Senior Enterprise Architect. No newsletter sign-up.