db2_fdw
db2_fdw : foreign data wrapper for DB2 access
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 8630 | db2_fdw
|
db2_fdw
|
18.1.1 |
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 | odbc_fdw
mysql_fdw
oracle_fdw
tds_fdw
wrappers
multicorn
jdbc_fdw
postgres_fdw
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG
|
18.1.1 |
18
17
16
15
14
|
db2_fdw |
- |
| RPM | PGDG
|
18.1.1 |
18
17
16
15
14
|
db2_fdw_$v |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PGDG 18.1.1
|
PGDG 18.1.1
|
PGDG 18.1.1
|
PGDG 18.1.1
|
PGDG 18.1.1
|
el8.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
el9.x86_64
|
PGDG 18.1.1
|
PGDG 18.1.1
|
PGDG 18.1.1
|
PGDG 18.1.1
|
PGDG 18.1.1
|
el9.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
el10.x86_64
|
PGDG 18.1.1
|
PGDG 18.1.1
|
PGDG 18.1.1
|
PGDG 18.1.1
|
PGDG 18.1.1
|
el10.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
d12.x86_64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
d12.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
d13.x86_64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
d13.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
u22.x86_64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
u22.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
u24.x86_64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
u24.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
| Package | Version | OS | ORG | SIZE | File URL |
|---|---|---|---|---|---|
db2_fdw_18 |
18.1.1 |
el8.x86_64 | pgdg | 79.1 KiB | db2_fdw_18-18.1.1-1PGDG.rhel8.10.x86_64.rpm |
db2_fdw_18 |
18.0.1 |
el8.x86_64 | pgdg | 70.6 KiB | db2_fdw_18-18.0.1-2PGDG.rhel8.x86_64.rpm |
db2_fdw_18 |
18.0.1 |
el8.x86_64 | pgdg | 70.6 KiB | db2_fdw_18-18.0.1-1PGDG.rhel8.x86_64.rpm |
db2_fdw_18 |
18.1.1 |
el9.x86_64 | pgdg | 72.2 KiB | db2_fdw_18-18.1.1-1PGDG.rhel9.7.x86_64.rpm |
db2_fdw_18 |
18.0.1 |
el9.x86_64 | pgdg | 64.4 KiB | db2_fdw_18-18.0.1-2PGDG.rhel9.x86_64.rpm |
db2_fdw_18 |
18.0.1 |
el9.x86_64 | pgdg | 64.3 KiB | db2_fdw_18-18.0.1-1PGDG.rhel9.x86_64.rpm |
db2_fdw_18 |
18.1.1 |
el10.x86_64 | pgdg | 73.1 KiB | db2_fdw_18-18.1.1-1PGDG.rhel10.1.x86_64.rpm |
db2_fdw_18 |
18.0.1 |
el10.x86_64 | pgdg | 65.4 KiB | db2_fdw_18-18.0.1-2PGDG.rhel10.x86_64.rpm |
db2_fdw_18 |
18.0.1 |
el10.x86_64 | pgdg | 65.3 KiB | db2_fdw_18-18.0.1-1PGDG.rhel10.x86_64.rpm |
Source
Install
Make sure PGDG repo available:
pig repo add pgdg -u # add pgdg repo and update cacheInstall this extension with pig:
pig install db2_fdw; # install via package name, for the active PG version
pig install db2_fdw -v 18; # install for PG 18
pig install db2_fdw -v 17; # install for PG 17
pig install db2_fdw -v 16; # install for PG 16
pig install db2_fdw -v 15; # install for PG 15
pig install db2_fdw -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION db2_fdw;Usage
Create Server
CREATE EXTENSION db2_fdw;
CREATE SERVER db2srv FOREIGN DATA WRAPPER db2_fdw
OPTIONS (dbserver 'SAMPLE');Server Options: dbserver (required, DB2 database connection string).
Create User Mapping
CREATE USER MAPPING FOR PUBLIC SERVER db2srv
OPTIONS (user 'db2inst1', password 'secret');Use empty strings for user and password to enable external authentication.
Create Foreign Table
CREATE FOREIGN TABLE employee (
empno char(6) OPTIONS (key 'true'),
firstname varchar(12),
lastname varchar(15),
salary numeric
)
SERVER db2srv
OPTIONS (schema 'DB2INST1', table 'EMPLOYEE');Table Options: table (required, DB2 table name, case-sensitive, typically uppercase), schema (table owner), readonly (default false), prefetch (rows per round-trip, default 200, range 0-10240), max_long (max LONG column length, default 32767).
Column Options: key (set to true for primary key columns, required for UPDATE/DELETE).
Import Foreign Schema
IMPORT FOREIGN SCHEMA "DB2INST1" FROM SERVER db2srv INTO public;Import Options: case (keep, lower, or smart, default smart), readonly.
CRUD Operations
SELECT * FROM employee WHERE empno = '000010';
INSERT INTO employee (empno, firstname, lastname, salary) VALUES ('999999', 'John', 'Doe', 50000);
UPDATE employee SET salary = 55000 WHERE empno = '999999';
DELETE FROM employee WHERE empno = '999999';Data Type Mapping
| DB2 Type | PostgreSQL Types |
|---|---|
| CHAR | char |
| VARCHAR | varchar |
| CLOB | text |
| BLOB | bytea |
| SMALLINT, INTEGER, BIGINT | smallint, integer, bigint |
| DOUBLE | numeric, float |
| DATE | date |
| TIMESTAMP | timestamp |
| TIME | time |
WHERE conditions and column projections are pushed down to DB2 to minimize data transfer.