mfvitale / postgres-oracle-fdw

Dockerfile for build a PostgreSQL image with Oracle Foreign Data Wrapper extension
MIT License
16 stars 8 forks source link
docker oracle-database postgresql postgresql-extension

Intro

All the oracle client library and FDW extention is in the sdk bacause is not possbile to get it through wget from Oracle site. If you need another version download it from Oracle site an put it into sdk folder.

Build image

docker build -t postgres-ora-fdw:11.4 .

Supported args

Arg default
postgres_version 11.4
oracle_fdw_version 2_1_0
instantclient_version 19_3

Example

docker build --build-arg postgres_version=10.4 -t postgres-ora-fdw:10.4 .

Run image

docker run -d --name test-postgres postgres-ora-fdw:11.4

Create Foreign Data Wrapper

Enter into container

docker exec -it test-postgres bash

then

psql

then create the extension and the connection to remote DB

CREATE EXTENSION oracle_fdw;
CREATE SERVER oradb FOREIGN DATA WRAPPER oracle_fdw
          OPTIONS (dbserver '//<host>:1521/<database>');
GRANT USAGE ON FOREIGN SERVER oradb TO postgres;
CREATE USER MAPPING FOR postgres SERVER oradb OPTIONS (user 'user', password 'password');

then import table (this is like creating a symbolic link to remote database, no data is imported)

IMPORT FOREIGN SCHEMA "<foreignSchemaName>"
    FROM SERVER oradb
    INTO <localSchemaName>;

more info on PostgreSQL docs.