Install the Oracle Instant Client and oracle_fdw so PostgreSQL can query Oracle tables through foreign data wrappers.
Installing the Oracle Instant Client plus the oracle_fdw
extension lets PostgreSQL connect to Oracle databases and treat remote Oracle tables as regular Postgres tables—ideal for migrations, reporting, or hybrid stacks.
64-bit Linux, build tools (gcc
, make
), libaio
, matching Postgres server headers, and Oracle Instant Client 19c+ (Basic or Basic Lite).
sudo apt-get update && sudo apt-get install -y libaio1 alien
wget https://download.oracle.com/otn_software/linux/instantclient/21_9/
oracle-instantclient-basiclite-21.9.0.0.0-1.x86_64.rpm
sudo alien -i oracle-instantclient-basiclite-21.9.0.0.0-1.x86_64.rpm
# make libraries visible
echo "export LD_LIBRARY_PATH=/usr/lib/oracle/21.9/client64/lib:$LD_LIBRARY_PATH" | \
sudo tee /etc/profile.d/oracle.sh
oracle_fdw
?git clone https://github.com/laurenz/oracle_fdw.git
cd oracle_fdw
make && sudo make install
-- inside psql
CREATE EXTENSION IF NOT EXISTS oracle_fdw;
CREATE SERVER oracle_srv FOREIGN DATA WRAPPER oracle_fdw
OPTIONS (dbserver '//ora-host:1521/ORCLPDB1');
CREATE USER MAPPING FOR current_user
SERVER oracle_srv
OPTIONS (user 'ora_user', password 'secret');
IMPORT FOREIGN SCHEMA ecommerce
FROM SERVER oracle_srv
INTO public
OPTIONS (case 'lower');
SELECT c.name, o.total_amount
FROM customers c -- Oracle (foreign)
JOIN orders o USING(id) -- PostgreSQL local
WHERE o.order_date > CURRENT_DATE - INTERVAL '30 days';
Pin Instant Client versions, use least-privilege Oracle users, monitor session counts, and automate installs with Docker or Ansible.
Missing LD_LIBRARY_PATH
causes libclntsh.so not found; mismatched 32-/64-bit libraries prevent oracle_fdw
from compiling.
Replace the Instant Client directory, recompile oracle_fdw
, then ALTER EXTENSION oracle_fdw UPDATE
. To remove, DROP EXTENSION oracle_fdw
and delete client libraries.
Yes. Run brew install oracle-instantclient
, then build oracle_fdw
with make
. Remember to update DYLD_LIBRARY_PATH
.
You need superuser or a role with CREATE EXTENSION
privilege to install oracle_fdw
. After installation, regular users can query the foreign tables.
Yes. Many companies run it in production. Test thoroughly, monitor connection counts, and pin client versions to avoid breaking changes.