oracle_fdw installs a foreign data wrapper that allows PostgreSQL to query Oracle tables under an open-source license.
oracle_fdw is an open-source foreign data wrapper (FDW) that lets PostgreSQL run SQL against Oracle databases as if their tables lived locally. The code ships under Oracle’s Universal Permissive License (UPL), giving teams commercial flexibility.
FDWs avoid batch copies. Queries run in real time, reducing data staleness, storage cost, and pipeline maintenance. Developers can join Oracle data with local tables in one statement.
On most Linux systems, compile from source with Oracle Instant Client headers, then run CREATE EXTENSION oracle_fdw;
in PostgreSQL. Windows builds require MSVC and the same client libraries.
After installing the extension, define a foreign server pointing at the Oracle listener, create a user mapping with Oracle credentials, and import or manually create foreign tables.
CREATE SERVER oracle_srv FOREIGN DATA WRAPPER oracle_fdw OPTIONS (dbserver '//ora-host:1521/ORCLPDB1');
CREATE USER MAPPING FOR app_user SERVER oracle_srv OPTIONS (user 'ORA_APP', password 'secret');
IMPORT FOREIGN SCHEMA HR LIMIT TO (PRODUCTS) FROM SERVER oracle_srv INTO public;
Once products
is a foreign table, you can join it with local orderitems
to calculate revenue on the fly.
Use read-only Oracle accounts, tune oracle_fdw
fetch_size
, and index join columns on both sides. Monitor query plans to confirm Oracle predicates are pushed down.
Missing Oracle client libraries: the extension will fail to build; install the 21c Instant Client first. Forgetting to set LD_LIBRARY_PATH: PostgreSQL cannot find libclntsh.so
; export the path or add it to /etc/ld.so.conf.d/
.
Yes. Map Oracle’s PRODUCTS
table, then join it with local Orders
and OrderItems
to enrich reports without ETL.
Yes. The project is released under the Oracle Universal Permissive License (UPL), a permissive open-source license similar to MIT.
Most WHERE clauses and aggregates are executed on the Oracle side, reducing network traffic. Check EXPLAIN output for Oracle query
lines.
INSERT, UPDATE, and DELETE are supported if the foreign table has a primary key and your Oracle user has the required privileges.