db2_fdw
db2_fdw : foreign data wrapper for DB2 access
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 8630 | db2_fdw | db2_fdw | 18.2.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 | db_migrator db2fce pg_statement_rollback mysql_fdw orafce postgres_fdw tds_fdw oracle_fdw sqlite_fdw informix_fdw |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG | 18.2.0 |
18 17 16 15 14 | db2_fdw |
- |
| RPM | PGDG | 18.2.0 |
18 17 16 15 14 | db2_fdw_$v |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 18.2.0 | PGDG 18.2.0 | PGDG 18.2.0 | PGDG 18.2.0 | PGDG 18.2.0 |
| el8.aarch64 | N/A | N/A | N/A | N/A | N/A |
| el9.x86_64 | PGDG 18.2.0 | PGDG 18.2.0 | PGDG 18.2.0 | PGDG 18.2.0 | PGDG 18.2.0 |
| el9.aarch64 | N/A | N/A | N/A | N/A | N/A |
| el10.x86_64 | PGDG 18.2.0 | PGDG 18.2.0 | PGDG 18.2.0 | PGDG 18.2.0 | PGDG 18.2.0 |
| el10.aarch64 | N/A | N/A | N/A | N/A | N/A |
| d12.x86_64 | N/A | N/A | N/A | N/A | N/A |
| d12.aarch64 | N/A | N/A | N/A | N/A | N/A |
| d13.x86_64 | N/A | N/A | N/A | N/A | N/A |
| d13.aarch64 | N/A | N/A | N/A | N/A | N/A |
| u22.x86_64 | N/A | N/A | N/A | N/A | N/A |
| u22.aarch64 | N/A | N/A | N/A | N/A | N/A |
| u24.x86_64 | N/A | N/A | N/A | N/A | N/A |
| u24.aarch64 | N/A | N/A | N/A | N/A | N/A |
| u26.x86_64 | N/A | N/A | N/A | N/A | N/A |
| u26.aarch64 | N/A | N/A | N/A | N/A | N/A |
Source
github.com/wolfgangbrandl/db2_fdw
db2_fdw-18.1.1.tar.gz
Install
Make sure PGDG repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources: README, current upstream README
db2_fdw is a PostgreSQL foreign data wrapper for querying and modifying IBM Db2 tables from PostgreSQL. It pushes down required columns and WHERE conditions where possible, and provides helper functions for connection cleanup and diagnostics.
Create Server
Server options: dbserver (required Db2 connection string), batch_size (currently reserved for future batch behavior), and no_encoding_error (ON, OFF, YES, NO, TRUE, or FALSE).
Create User Mapping
Use empty strings for user and password to enable external authentication through the Db2 client environment.
Create Foreign Table
Table options: table (required, Db2 table name or simple query, case-sensitive, typically uppercase), schema (table owner), readonly (default false), sample_percent (ANALYZE sampling), prefetch (rows per round-trip, default 100, range 0-1024), fetch_size (accepted but currently fixed at 1), batch_size, and no_encoding_error. max_long is documented upstream as deprecated and no longer used.
Column options: key (set to true for all primary key columns, required for UPDATE and DELETE), plus Db2 metadata options such as db2type, db2size, db2bytes, db2chars, db2scale, db2null, and db2ccsid on imported tables.
Import Foreign Schema
Import Options: case (keep, lower, or smart, default smart), readonly.
CRUD Operations
Connection Helpers
db2_close_connections() closes cached Db2 connections in the current session. db2_diag() reports db2_fdw, PostgreSQL, Db2 client, and optionally remote server diagnostic details.
Data Type Mapping
| DB2 Type | PostgreSQL Types |
|---|---|
| CHAR | char |
| VARCHAR | varchar |
| CLOB | text |
| VARGRAPHIC, GRAPHIC | 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.