Why this migration is different
Oracle to PostgreSQL is the most requested — and most underestimated — enterprise database migration. The databases share SQL syntax at the surface level, which creates a dangerous illusion of compatibility. The real challenges are deeper: PL/SQL conversion, Oracle-specific data types, partitioning strategies, and optimizer behaviour differences.
Data type mapping: the non-obvious cases
The straightforward mappings (NUMBER → NUMERIC, VARCHAR2 → VARCHAR) are well documented. These are the ones that cause production issues:
DATEin Oracle includes time; in PostgreSQL,DATEis date-only. UseTIMESTAMPinstead.NUMBERwithout precision in Oracle is a floating-point number. Map toNUMERICorDOUBLE PRECISIONdepending on usage.CLOB/BLOB→TEXT/BYTEA, but PostgreSQL has a 1GB limit onTEXTfields. If your CLOBs exceed this, you need an external storage strategy.RAW→BYTEA, but the hex encoding is different. Conversion must handle this at the application layer.INTERVALtypes have different syntax between Oracle and PostgreSQL.
PL/SQL to PL/pgSQL: the hard part
Oracle PL/SQL and PostgreSQL PL/pgSQL look similar but differ in critical ways:
- Package support: Oracle packages don't exist in PostgreSQL. Each procedure and function must be standalone, and package-level variables must be replaced with session variables or schema-level functions.
- Exception handling: Oracle's
WHEN OTHERS THENmaps to PostgreSQL'sEXCEPTION WHEN OTHERS THEN, but the error codes are completely different. - Autonomous transactions: Oracle supports
PRAGMA AUTONOMOUS_TRANSACTION. PostgreSQL requiresdblinkor a separate connection — a significant architectural change. - Cursors: Oracle's implicit cursors don't exist in PostgreSQL. Every cursor must be explicitly declared.
- CONNECT BY: Oracle's hierarchical query syntax must be rewritten using PostgreSQL's recursive CTEs (
WITH RECURSIVE).
Dflux.ai approach: Our Compatibility Agent uses AI-powered analysis to convert PL/SQL to PL/pgSQL, handling package decomposition, cursor conversion, and exception mapping automatically. It generates a compatibility report flagging any constructs that require manual review.
Partitioning strategy differences
Oracle's partitioning is more mature and flexible. When migrating:
- Oracle range-range composite partitioning → PostgreSQL supports this natively since v12, but the syntax is different.
- Oracle hash partitioning → PostgreSQL hash partitioning works differently. Partition count must be a power of 2 for optimal distribution.
- Oracle interval partitioning (auto-create partitions) → PostgreSQL requires
pg_partmanextension or manual partition management.
Performance tuning post-migration
The Oracle optimizer and PostgreSQL planner make different decisions. After migration:
- Run
ANALYZEon all tables to populate PostgreSQL statistics. - Review execution plans for your top 20 queries. Oracle hint-based tuning doesn't translate — PostgreSQL uses cost-based optimization exclusively.
- Adjust
work_mem,shared_buffers, andeffective_cache_sizebased on your workload profile. - Consider
pg_stat_statementsfor ongoing query performance monitoring.
Ready to automate your next migration?
See how Dflux.ai handles schema mapping, validation, and rollback automatically.
Book a Free Demo →