dblink
connect to other PostgreSQL databases from within a database
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
dblink | 1.2 | FDW | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 8970 | dblink | No | Yes | No | Yes | No | No | - |
| Related | postgres_fdw db_migrator pgspider_ext pglogical citus pgclone plproxy mimeo mysql_fdw db2_fdw |
|---|---|
| Depended By | emaj mimeo omni_schema omni_test omni_vfs pg_jobmon pg_profile pgbouncer_fdw pgelog |
Version
| PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|
| 1.2 | 1.2 | 1.2 | 1.2 | 1.2 |
Install
Note: This is a built-in contrib extension of PostgreSQL
Usage
dblink: Connect to other PostgreSQL databases from within a database
Connect to a Remote Database
Or connect via a foreign server definition:
Query a Remote Database
You must always specify the column definition list in the AS clause.
Execute Commands (No Result Set)
Returns the command status string (e.g., INSERT 0 1).
Cursor-Based Access
Connection Management
Create a View for Convenience
Key Functions
| Function | Description |
|---|---|
dblink_connect(connstr) | Open an unnamed persistent connection |
dblink_connect(name, connstr) | Open a named persistent connection |
dblink_disconnect(name) | Close a named connection |
dblink(connstr, sql) | Execute a query, return rows |
dblink_exec(connstr, sql) | Execute a command, return status |
dblink_open(name, cursor, sql) | Open a cursor on a remote database |
dblink_fetch(name, cursor, count) | Fetch rows from a remote cursor |
dblink_close(name, cursor) | Close a remote cursor |
dblink_get_connections() | List all open named connections |
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)