How to migrate from Oracle to PostgreSQL with Ora2Pg
A team moving from Oracle to PostgreSQL can expect the work to be sized by five things: schema size, PL/SQL volume, data volume, downtime tolerance and the amount of Oracle-specific SQL in the applications. Ora2Pg is the open-source tool that produces the assessment that measures these factors, so the first decision is whether to run that assessment before anyone commits to a plan or scope, and who on your side owns the output. Each factor pulls the effort in a different direction. A large schema with simple tables is mostly a data movement exercise. A smaller schema full of packages, triggers and procedures is mostly a code conversion exercise. Tight downtime limits push the design toward an offline load with a rehearsed cutover, and heavy use of Oracle-only SQL in the application adds work that no schema tool can finish on its own.
The assessment is a starting point rather than a finished estimate. Ask the team running it to show which objects it could convert automatically, which it flagged for manual rewrite and which it could not classify, because that split is what determines the effort. Confirm the Oracle version and edition in use, the character sets, any Oracle features the database depends on, and which application teams own the SQL that must change. Also confirm the PostgreSQL major version you will target. The PostgreSQL versioning policy lists the supported versions and their end-of-life dates, and a target that will leave support soon creates a second migration you should plan for now.
Ora2Pg is the tool most often used to run this assessment, and its report is only useful if someone reviews it against your own objects. Compare the counts it gives with an inventory from your Oracle data dictionary, and check that every package and trigger appears in the report with a status. Treat the results as input to a written scope that lists which objects move, which are rewritten, which are retired and how data will be validated before cutover. Without that scope, the assessment becomes a long list of warnings with no owner and no decision attached.
What maps cleanly from Oracle to PostgreSQL
This table compares common Oracle features with their PostgreSQL equivalents and marks whether each usually converts automatically, needs a manual rewrite, or has no direct equivalent that the team must design around. Use it to size the rewrite work before running the Ora2Pg assessment, and treat the labels as starting points to confirm against your own schema and code.
| Oracle feature | PostgreSQL equivalent | Typical handling | Migration note |
|---|---|---|---|
| Tables and constraints | Tables, primary keys, foreign keys, check constraints | Usually converts automatically | Review constraint deferral and NOT VALID handling, and confirm how Oracle-only constraint states were exported. |
| Sequences | Sequences and identity columns | Usually converts automatically | Reset sequence values after the data load so new inserts do not collide with migrated keys. |
| Views | Views | Usually converts automatically | Check functions and hints inside view definitions, since Oracle syntax such as NVL or DECODE needs rewriting. |
| Indexes | B-tree, GIN, GiST and other index types | Usually converts automatically | Bitmap and function-based indexes need review. Confirm which index types PostgreSQL supports for each use case. |
| Packages, procedures and functions | PL/pgSQL functions and procedures, with schemas used for grouping | Manual rewrite | PL/SQL packages have no direct equivalent, so package state and overloading must be redesigned as schemas, functions and session settings. |
| Triggers | PL/pgSQL trigger functions bound to CREATE TRIGGER | Manual rewrite | Trigger logic must move into trigger functions, and compound triggers need restructuring into separate triggers. |
| Partitioning | Declarative partitioning by range, list or hash | Manual rewrite | Partition layouts and local index definitions must be re-created and checked for PostgreSQL partition key rules. |
| Synonyms | Views, search_path or schema qualification | Manual rewrite | No public synonym feature exists, so decide how application names resolve and set search_path deliberately. |
| Database links | postgres_fdw or dblink | No direct equivalent | Remote access must be redesigned with extensions, credentials and network paths that your security team approves. |
| Materialized views | Materialized views with REFRESH MATERIALIZED VIEW | Manual rewrite | Refresh scheduling and fast refresh behavior differ, so plan refresh jobs explicitly. |
| Scheduler jobs | pg_cron, external schedulers or cron | No direct equivalent | DBMS_SCHEDULER jobs must be rebuilt in a scheduler you operate, with monitoring and retry behavior defined. |
| Oracle-specific data types | Numeric, varchar, timestamp with time zone, bytea, text, json or jsonb | Manual rewrite | NUMBER, VARCHAR2 and DATE need mapping decisions, since DATE in Oracle carries time, and the mapping must be tested with real values. |
Which documented tools move Oracle schemas and data
Ora2Pg is the documented open-source tool for this path, and each step it supports produces an artifact you review before the next one starts. The cards below follow the order of work: assess, convert, load, then check. Standard PostgreSQL tools cover the last two steps, so the team keeps control of the target database throughout.
Assessment report from Ora2Pg
Ora2Pg reads the Oracle data dictionary and produces a migration assessment that scores how much of the schema, PL/SQL and data types can convert automatically. Use it to size the work before committing to a plan. Treat the score as a starting estimate, not a delivery estimate. Review every object the report flags as manual, including packages, triggers, sequences and Oracle-specific types.
Schema and code conversion
Ora2Pg exports tables, indexes, constraints, sequences and views as PostgreSQL DDL, and it translates much of the PL/SQL into PL/pgSQL. The output is a draft. Packages, autonomous transactions, collections, dynamic SQL and exception handling usually need hand rewriting and tests against the same inputs. Keep the generated files in version control so each change is traceable.
Data export from Oracle
Ora2Pg exports table data to files or streams it into the target, and it can apply type mappings for dates, LOBs, numbers and character sets. Confirm the Oracle client libraries, the Ora2Pg version and any driver requirements against the project documentation for your operating system and Oracle release. Check how LOB columns, BLOB data and NLS settings are exported before running a full load.
Load and checks with PostgreSQL tools
Once the DDL is applied, bulk data is typically loaded with COPY, and psql runs the scripts, sequence resets and index builds in a controlled order. Plan the load window around constraints and index creation, which often take longer than the data copy itself. Record row counts and checksums per table so the cutover team has a repeatable comparison.
Manual review and sign-off
Assign an owner to every item the assessment and conversion flagged, including application SQL that depends on Oracle functions, implicit type conversions and case sensitivity. Compare query results between Oracle and PostgreSQL for representative workloads. Confirm the final Ora2Pg version, Oracle client requirements and PostgreSQL target version with the project documentation and your DBA before scheduling cutover.
How schema, code and data move through the Oracle migration
The diagram starts at the Oracle source, where schema, PL/SQL and data are exported, and runs through an Ora2Pg assessment and export into a manual review of converted PL/SQL. The converted schema builds the PostgreSQL target, which receives an offline data load. Validation gates the parallel run, and only a clean comparison leads to cutover. The manual review and validation steps are the points where most of the effort and risk sit.
Schema, code and data paths from Oracle to cutover, with manual steps marked.
Sequence for an Oracle to PostgreSQL migration with parallel run and cutover
This sequence moves an Oracle workload to PostgreSQL in gated stages, so each schema, load and cutover decision has a named owner and a recorded sign-off before the next stage begins. The result is a validated PostgreSQL cluster, a tested rollback path and a dated plan for retiring Oracle.
Inventory schemas, code and connections
The team lists every schema, PL/SQL package, procedure, function, trigger, scheduled job, database link and application connection string that touches the Oracle database, and records the owner of each. Application teams confirm which connections are live and which are stale. The gate is a signed inventory from the database owner and the application owners, with anything not listed explicitly marked as out of scope.
Run the Ora2Pg assessment report
Ora2Pg connects to the Oracle source with read-only access and produces an assessment report that scores objects by how much manual work they need. Engineers review the report against the inventory and flag objects the tool cannot convert, such as Oracle-specific features that have no direct PostgreSQL equivalent. The gate is a reviewed report that the migration lead accepts as the basis for effort planning.
Review conversions and rewrite PL/SQL
Engineers review the generated DDL and the converted PL/SQL code, then rewrite objects that depend on Oracle behavior into PL/pgSQL by hand. Each rewrite is paired with a test that shows the original and new code return the same results for representative inputs. The gate is a code review record where the DBA and the application lead sign off on every rewritten object.
Pilot load into a non-production cluster
The team loads a subset of the schema and data into a non-production PostgreSQL cluster built to the target configuration, which may run a version such as 17 or 18 depending on the supported version chosen for the project. The pilot exposes type mismatches, collation differences, sequence gaps and slow objects. The gate is a pilot report listing every failed object and its fix, approved by the DBA.
Rehearse the offline data load
The full load is run at least once against a copy of production data, with timings recorded for export, transfer, import, index creation and sequence reset. Each rehearsal is compared with the previous one so the cutover window is planned from measured times rather than estimates. The gate is a rehearsal log that the operations lead and the business owner review before setting the production cutover window.
Run the parallel period with reconciliation
Oracle stays the system of record while the application or a replica feeds PostgreSQL, and the team compares row counts, checksums and business totals on agreed tables on a fixed schedule. Discrepancies are logged, traced to a root cause and fixed before the next comparison. The gate is a reconciliation report showing that all agreed tables match, or that each remaining difference has an approved explanation and owner.
Cut over with a documented rollback path
The team freezes writes on Oracle, runs the final data load and sequence reset, repoints application connections and runs smoke tests against PostgreSQL. The rollback path, including the conditions that trigger it and the steps to reverse the connection change, is written and rehearsed before the window opens. The gate is a go or no-go decision by the business owner, recorded with the smoke test results.
Decommission Oracle after retention
Oracle stays available in read-only mode for a retention period agreed in writing before cutover, so the team can compare data and reverse the change if a defect appears. Once the period ends and the business owner accepts the result, backups are archived under the organization's retention policy and the Oracle licenses and servers are retired. The gate is a closure record signed by the business owner, the CISO or delegate and the database owner.
Converting PL/SQL to PL/pgSQL during an Oracle migration
Stored code needs a different plan from tables and data, because PL/SQL features do not map one to one onto PL/pgSQL. Packages have no direct PostgreSQL equivalent, so teams usually turn them into schemas with functions and shared state handled deliberately. Autonomous transactions, collections used with BULK COLLECT and FORALL, exception handling with named Oracle exceptions, dynamic SQL built with EXECUTE IMMEDIATE, and Oracle-specific built-ins such as date and string functions each need a decision about the target construct. Ora2Pg produces a migration assessment that flags many of these objects, and that report is the starting inventory, not a finished conversion. Confirm the report's version and object counts against your own source catalog before you plan effort.
Sort every routine into one of three groups before anyone edits code. Routines that use only plain SQL, simple control flow and built-ins with clear equivalents can go through automatic conversion, with a sample diff review. Routines with packages, collections, bulk operations or exception logic go to reviewed conversion, where a developer who knows both dialects checks each change. Routines that depend on autonomous transactions, heavy dynamic SQL or undocumented Oracle behavior usually need a full rewrite, and the design of the replacement should be agreed with the application owner. Record the group, owner and decision for each object in a tracking sheet so the scope stays visible.
Test each converted routine against known inputs and expected outputs captured from the Oracle source. Run the same input sets through both databases, compare return values, row counts, rows changed and raised error codes, and keep the test data under version control. Pay particular attention to NULL handling, numeric rounding, date arithmetic and sort order, because these differ quietly between the two engines. Include error paths and transaction boundaries in the tests, not only happy paths. Ask your team to confirm which test harness they will use and who signs off each routine before cutover.
What drives Oracle to PostgreSQL migration effort and duration
This table lists the factors that change how much work an Oracle to PostgreSQL migration takes and how long it runs. Read each row for the kind of effort it adds, whether that effort is one-time or recurring, and what to ask a partner or your own team to state in a quote. No durations or prices are given because they depend on your estate and must come from a written scope.
| Driver | Why it changes effort | One-time or recurring | What to ask for in a quote |
|---|---|---|---|
| PL/SQL volume and complexity | Packages, procedures, triggers and custom types must be converted to PL/pgSQL, and Oracle-only constructs such as autonomous transactions or package state need redesign rather than direct translation | One-time | Object inventory by type, a list of constructs flagged as manual, and the conversion approach for each |
| Schema and object count | More schemas, sequences, synonyms, materialized views and database jobs widen the assessment and the number of objects to verify after conversion | One-time | Counts per schema and object type from the assessment report, and the agreed object scope |
| Data volume and offline load window | Larger tables lengthen the initial load and the cutover window, and LOB-heavy tables take longer to move and validate | One-time, with repeat loads for each rehearsal | Data volume per schema, the load method, the agreed downtime window and the number of rehearsal loads included |
| Oracle-specific data types and features | Types such as NUMBER precision mapping, DATE with time semantics, RAW, XMLType, spatial types and Oracle sequences need explicit mapping decisions and tests | One-time | A type mapping table signed off by the client and the list of features that need replacements |
| Application SQL and driver changes | Embedded SQL, ORM mappings, Oracle hints, ROWNUM and dual-table queries, and JDBC or OCI driver switches touch application code owned by other teams | One-time for the port, recurring if the application keeps evolving on both engines during the transition | Inventory of application codebases, the query changes in scope and who owns the code changes |
| Database links and integrations | Each database link, external table, Oracle Advanced Queuing use or upstream feed must be rebuilt, secured and tested against PostgreSQL equivalents | One-time, and recurring if links stay in service during a parallel run | List of links and feeds with owners, and the replacement design for each |
| Validation depth | Row counts, checksums, business reconciliation and reporting comparisons range from light to exhaustive and drive most of the test effort | One-time, repeated on every rehearsal | Validation criteria written per table or business process and the evidence format delivered |
| Parallel run length and cutover rehearsals | Running both databases in step keeps reconciliation and rollback options open but adds operational load for the entire parallel period | Recurring for the length of the parallel run | Parallel run duration as an agreed input, rollback criteria and the number of cutover rehearsals |
| Client reviewers and testers | Business owners, application teams and the DBA team must review type decisions, test scenarios and sign-off evidence, and their availability sets the pace | One-time, but often the longest dependency | Named reviewers by area, their time commitment in writing and the sign-off points in the plan |
What usually goes wrong in Oracle to PostgreSQL migrations
Most Oracle to PostgreSQL problems do not show up as failed loads. They appear as numbers that round differently, sequences that start too low, or PL/SQL that only breaks when a rarely used path runs. Each risk below has a prevention step tied to a specific stage of the migration, so checks happen before cutover rather than after users report errors.
Silent number, date and string differences
Oracle's NUMBER type, DATE type (which carries a time component) and empty-string handling do not match PostgreSQL's defaults. A DATE column converted as a date-only type drops time values, and Oracle treats an empty string as NULL where PostgreSQL does not. Check these mappings in the Ora2Pg assessment output and confirm them with sample rows during the schema conversion review, before any data moves.
Sequences and identity columns out of step
Data loads insert explicit key values, so PostgreSQL sequences keep their starting values and the next application insert can collide with existing rows. Reset every sequence to the maximum loaded value as a scripted step after the data load and before the application connects. Add this to the cutover runbook so it runs every time, not only in the first test.
Collation and encoding mismatches
Sort order, case comparison and accent handling depend on the collation and encoding of the target database. A database created with a different collation than the Oracle source can return rows in a different order and make unique constraints or indexes behave differently. Decide the database encoding and collation during the target design, record them, and test sorting on real text columns in the staging environment.
PL/SQL that fails only at runtime
Packages, procedures and triggers that Ora2Pg cannot convert automatically may still load without error and fail only when a specific branch runs, such as an error handler or a month-end job. Inventory every object the assessment flags as manual, then run each one through a test suite that covers the rare paths. Treat code that was not exercised in staging as untested.
Application SQL that assumes Oracle behavior
Applications often rely on Oracle-specific syntax such as ROWNUM, CONNECT BY, outer join operators written with plus signs, and implicit type conversion in comparisons. PostgreSQL rejects some of these and returns different results for others. Collect the SQL the application actually sends, including ORM-generated statements, and review it against the target before the application team signs off.
Missing reconciliation before cutover
Without row counts, checksums and sampled business totals compared between source and target, a migration can pass every technical check and still have missing or altered data. Agree on the reconciliation queries with the business owners before the offline load, run them after each full test load, and set the pass criteria in writing. A cutover without signed-off reconciliation results should not go ahead.
Validating data before cutover in a planned Oracle migration
Validation starts with the offline data load plan, because the checks only mean something if the load itself is controlled. Set the load order so parent tables load before the tables that reference them, and decide in advance whether foreign keys, check constraints and unique indexes are created before or after the bulk load. Creating indexes after the load is usually faster, but the constraint decision has to be recorded so nobody later assumes the data was checked against rules it never faced. After the load, reset each sequence to a value above the highest migrated key, using the setval function for each sequence, and confirm the result. Schedule the whole sequence of steps against your downtime window by timing a full rehearsal on a copy of production data, not by estimating from table sizes. The rehearsal timings are the only figures you can trust when you plan the window.
Validation then runs in layers, and each layer catches a different class of error. Compare row counts for every table, including tables with no business meaning, since a silent skip often shows up there first. Compute checksums on full tables where the data volume allows it, and on a fixed, documented sample of large tables where it does not. Run the constraint checks against the loaded data, such as foreign key orphans and unique violations, because Oracle and PostgreSQL differ on how some types, empty strings and case handling are stored. Compare sequence values against the maximum key in each table. Finally, run business reconciliation reports on both systems: account balances, open order totals, or whatever figures your finance and operations teams already sign off. Agree on those reports and their owners before the rehearsal, not during cutover.
The parallel run is where differences the load did not expose become visible. Keep the Oracle system live and read-only for reporting while the PostgreSQL copy serves the same queries or a replayed subset of real transactions, then compare the outputs daily. Typical findings include date and timestamp precision, rounding in numeric conversions, collation-dependent sort order and trigger logic that behaved differently after translation to PL/pgSQL. Log every difference with its root cause and decide whether it is a conversion defect to fix or an accepted, documented change in behavior. Set exit criteria for the parallel run in writing, including the number of consecutive clean reconciliation cycles required before cutover, and confirm them with the business owners of each report.
Questions buyers ask before hiring help for an Oracle to PostgreSQL move
How much does an Oracle to PostgreSQL migration cost?
The cost depends on the written scope, which is set by the assessment, so no price can be stated before that work is done. The main drivers are the number of schemas and objects, how much PL/SQL must be rewritten by hand, the data volume and the downtime window the business accepts. Costs fall into one-time work (assessment, conversion, data load, testing, cutover) and any recurring support after go-live. Ask any provider for a quote that lists each deliverable, the Oracle features in use, the assumptions about data volume and who owns test data. DeployOpen agrees fixed scope in writing before work starts and does not publish a price list, so the quote follows from the assessment.
How long does an Oracle to PostgreSQL migration take?
Duration is set by the amount of code to convert, the data volume, the number of applications that connect to the database and the allowed outage window. Teams with many packages, triggers and Oracle-specific features usually spend most of their time on PL/SQL rewrites and testing rather than on moving data. Start with the Ora2Pg assessment report, which counts objects and flags items needing manual work, and use it to build a schedule. Ask for milestones tied to that report, and confirm which dependencies (application freezes, test environment access, sign-off windows) sit with your team.
Can our own team run Ora2Pg without a partner?
Yes, a capable team can run Ora2Pg itself, since it is open-source and documented, and the assessment report is a practical place to begin. The harder work is judging what the report means: which PL/SQL converts cleanly, which Oracle features have no direct equivalent, and how data types and sequences should map to your applications. Teams that run it alone should confirm they have a DBA who knows both engines, developers who can test converted code, and a non-production environment with realistic data. A partner adds the most value where the codebase is large or the cutover window is tight.
What does the migration need from our DBAs and developers?
DBAs must provide schema access, export the source metadata, review type mappings and own the data load and reconciliation plan. Developers must identify the queries, packages and jobs the application depends on, then test converted PL/pgSQL and any driver or ORM changes. Both groups should agree on who signs off on each validation step before cutover. Ask the provider to name these handoffs in the scope so that neither side assumes the other owns a gap, particularly for scheduled jobs, database links and application SQL that Ora2Pg does not rewrite.
Which PostgreSQL version should we target for an Oracle migration?
Target a version that is still supported for the whole life of the new system. According to the PostgreSQL versioning policy, supported versions are 18 (final release November 14, 2030), 17 (to November 8, 2029), 16 (to November 9, 2028), 15 (to November 11, 2027) and 14 (to November 12, 2026), while 13 and earlier are unsupported. Choosing 18 gives the longest support window. Confirm the version with your application vendors and extension requirements before the conversion starts, because changing the target later means repeating testing.
How are cutover and rollback handled in an Oracle to PostgreSQL move?
A typical plan freezes writes on Oracle, performs a final data load, runs reconciliation checks, switches application connection strings and keeps Oracle intact as a fallback until the new system is accepted. The rollback plan must state the point of no return, how writes made on PostgreSQL would be carried back if needed, and who decides to roll back. Validation includes row counts, checksums on key tables, sequence values and application test cases. Agree the rollback steps and decision owner in writing before the cutover window, and rehearse the full sequence in a non-production environment.
How DeployOpen scopes and delivers an Oracle to PostgreSQL migration
DeployOpen plans, builds and hands over Oracle to PostgreSQL migrations inside infrastructure you control, using Ora2Pg as the conversion tool. We agree the scope in writing before work starts, then test, document and transfer the result so your own team can run the new database.
How we scope
- We review your Oracle schemas, PL/SQL packages, data volumes and application connections before agreeing the migration boundary.
- The written scope names which schemas, objects, jobs and applications move, and which stay on Oracle.
- Engagements are fixed-scope, so deliverables, acceptance tests and timelines are agreed in writing before work starts.
How we build
- We run the Ora2Pg assessment report and turn its findings into a ranked list of manual PL/SQL to PL/pgSQL rewrites.
- We plan the offline data load, including load order, sequences, indexes and constraints, and rehearse it in a non-production environment.
- We build validation checks that compare row counts, key data and selected business results between Oracle and PostgreSQL before cutover.
How we hand over
- You receive the converted schema, rewritten code, load runbook, validation results and a list of known differences in behavior.
- We document the target PostgreSQL configuration, authentication settings and backup approach so your operators can run it.
- We walk your database, application and operations teams through the cutover runbook and rollback steps before go-live.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after cutover, based on the written scope.
- Post-cutover support can cover query tuning, rewritten code fixes and reviews of PostgreSQL minor and major upgrade plans.
- Ask for a quote that separates one-time conversion work from any recurring support so you can compare it with your own team's effort.

