dblink
connect to other PostgreSQL databases from within a database
dblink : connect to other PostgreSQL databases from within a database
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 8970 | dblink | dblink | 1.2 |
FDW | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
| Relationships | |
|---|---|
| Need By | emaj mimeo omni_schema omni_test omni_vfs pg_jobmon pg_profile pgbouncer_fdw pgelog |
| See Also | postgres_fdw db_migrator pgspider_ext pglogical citus pgclone plproxy mimeo mysql_fdw db2_fdw |
Packages
| PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|
| 1.2 | 1.2 | 1.2 | 1.2 | 1.2 |
This is a built-in contrib extension ship with the PostgreSQL kernel
Install
Create this extension with:
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 |