oracle_fdw lets PostgreSQL read and join Oracle tables through the Foreign Data Wrapper interface.
oracle_fdw streams Oracle rows on demand, eliminating nightly copies and keeping data fresh.
Install the Oracle Instant Client, compile oracle_fdw from source, then run CREATE EXTENSION oracle_fdw;
in the target database.
The PostgreSQL superuser installs the extension.Ordinary users need USAGE on the FDW server and SELECT on foreign tables.
Use CREATE SERVER
with connection details, then CREATE USER MAPPING
for credentials.
CREATE SERVER oradb FOREIGN DATA WRAPPER oracle_fdw OPTIONS (dbserver 'ORCLPDB1');
CREATE USER MAPPING FOR app_user SERVER oradb OPTIONS (user 'ora_user', password 'secret');
Run IMPORT FOREIGN SCHEMA
or create foreign tables manually to map specific columns and data types.
IMPORT FOREIGN SCHEMA ecommerce FROM SERVER oradb INTO public
OPTIONS (schema 'ECOM', import_default 'false');
oracle_fdw pushes WHERE clauses and some JOINs, reducing network traffic.Use EXPLAIN
to verify pushdown.
Create local tables alongside foreign tables, then write standard SQL joins.PostgreSQL handles execution.
SELECT c.name, o.total_amount
FROM Customers c
JOIN orders_from_oracle o ON o.customer_id = c.id
WHERE o.order_date > CURRENT_DATE - INTERVAL '30 days';
Index Oracle columns used in joins or filters, limit selected columns, and avoid large cross-database sorts.
Enable log_min_messages = debug1
in postgresql.conf
to capture oracle_fdw diagnostics, and check Oracle listener logs.
.
Yes, it’s licensed under PostgreSQL’s permissive license on GitHub.
Yes. INSERT, UPDATE, and DELETE are supported if the Oracle user has privileges.
It relies on Oracle’s network encryption (SQL*Net). Configure this in the Oracle client and server, not in PostgreSQL.