oracle_fdw
oracle_fdw : foreign data wrapper for Oracle access
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 8610 | oracle_fdw
|
oracle_fdw
|
2.8.0 |
FDW
|
PostgreSQL
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d--
|
No
|
Yes
|
No
|
Yes
|
no
|
no
|
| Relationships | |
|---|---|
| See Also | mysql_fdw
tds_fdw
db2_fdw
firebird_fdw
orafce
wrappers
odbc_fdw
jdbc_fdw
|
require oracle-libs
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG
|
2.8.0 |
18
17
16
15
14
|
oracle_fdw |
- |
| RPM | PGDG
|
2.8.0 |
18
17
16
15
14
|
oracle_fdw_$v |
- |
| DEB | PGDG
|
2.8.0 |
18
17
16
15
14
|
postgresql-$v-oracle-fdw |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
el8.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
el9.x86_64
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
el9.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
el10.x86_64
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
el10.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
d12.x86_64
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
d12.aarch64
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
d13.x86_64
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
d13.aarch64
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
u22.x86_64
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
u22.aarch64
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
u24.x86_64
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
u24.aarch64
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
PGDG 2.8.0
|
Source
Install
Make sure PGDG repo available:
pig repo add pgdg -u # add pgdg repo and update cacheInstall this extension with pig:
pig install oracle_fdw; # install via package name, for the active PG version
pig install oracle_fdw -v 18; # install for PG 18
pig install oracle_fdw -v 17; # install for PG 17
pig install oracle_fdw -v 16; # install for PG 16
pig install oracle_fdw -v 15; # install for PG 15
pig install oracle_fdw -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION oracle_fdw;Usage
Create Server
CREATE EXTENSION oracle_fdw;
CREATE SERVER oradb FOREIGN DATA WRAPPER oracle_fdw
OPTIONS (dbserver '//dbserver.mydomain.com:1521/ORADB');Server Options: dbserver (required, Oracle connection string), isolation_level (serializable, read_committed, or read_only, default serializable), nchar (expensive character conversion, default off), set_timezone (sync timezone with Oracle, default off).
Create User Mapping
CREATE USER MAPPING FOR pguser SERVER oradb
OPTIONS (user 'orauser', password 'orapwd');Use an empty string for user to enable external (OS) authentication.
Create Foreign Table
CREATE FOREIGN TABLE oratab (
id integer OPTIONS (key 'true') NOT NULL,
text character varying(30),
floating double precision NOT NULL
)
SERVER oradb
OPTIONS (schema 'ORAUSER', table 'ORATAB');Table Options: table (required, Oracle table name in uppercase), schema (table owner), dblink (Oracle DB link), max_long (max LONG column length, default 32767), readonly (default false), sample_percent (ANALYZE sampling, default 100), prefetch (rows per round-trip, default 50).
Column Options: key (mark as primary key, required for UPDATE/DELETE), strip_zeros (remove ASCII 0 from strings).
You can also use a query instead of a table name by enclosing it in parentheses:
CREATE FOREIGN TABLE oraquery (
id integer,
text character varying(30)
)
SERVER oradb
OPTIONS (table '(SELECT id, text FROM ORAUSER.ORATAB WHERE id > 10)');Import Foreign Schema
IMPORT FOREIGN SCHEMA "ORAUSER"
FROM SERVER oradb INTO local_schema;Import Options: case (keep, lower, or smart, default smart), readonly, skip_tables, skip_views, skip_matviews, max_long, sample_percent, prefetch.
Utility Functions
SELECT oracle_diag(); -- Show versions and environment info
SELECT oracle_diag('oradb'); -- Include Oracle server version
SELECT oracle_close_connections(); -- Close all cached Oracle connections
SELECT oracle_execute('oradb', 'TRUNCATE TABLE ORAUSER.ORATAB'); -- Execute arbitrary Oracle SQLData Type Mapping
| Oracle Type | PostgreSQL Types |
|---|---|
| CHAR, VARCHAR2, NVARCHAR2 | char, varchar, text |
| CLOB, NCLOB | text, json |
| NUMBER | numeric, float4, float8, int2, int4, int8, boolean |
| DATE, TIMESTAMP | date, timestamp, timestamptz |
| BLOB, LONG RAW | bytea |
| XMLTYPE | xml, text |
| SDO_GEOMETRY | geometry (PostGIS) |