> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/appendixes/contrib/dblink.md).

# F.11. dblink — connect to other PostgreSQL databases \#

[dblink\_connect](/appendixes/contrib/dblink/contrib-dblink-connect.md) — opens a persistent connection to a remote database

[dblink\_connect\_u](/appendixes/contrib/dblink/contrib-dblink-connect-u.md) — opens a persistent connection to a remote database, insecurely

[dblink\_disconnect](/appendixes/contrib/dblink/contrib-dblink-disconnect.md) — closes a persistent connection to a remote database

[dblink](/appendixes/contrib/dblink/contrib-dblink-function.md) — executes a query in a remote database

[dblink\_exec](/appendixes/contrib/dblink/contrib-dblink-exec.md) — executes a command in a remote database

[dblink\_open](/appendixes/contrib/dblink/contrib-dblink-open.md) — opens a cursor in a remote database

[dblink\_fetch](/appendixes/contrib/dblink/contrib-dblink-fetch.md) — returns rows from an open cursor in a remote database

[dblink\_close](/appendixes/contrib/dblink/contrib-dblink-close.md) — closes a cursor in a remote database

[dblink\_get\_connections](/appendixes/contrib/dblink/contrib-dblink-get-connections.md) — returns the names of all open named dblink connections

[dblink\_error\_message](/appendixes/contrib/dblink/contrib-dblink-error-message.md) — gets last error message on the named connection

[dblink\_send\_query](/appendixes/contrib/dblink/contrib-dblink-send-query.md) — sends an async query to a remote database

[dblink\_is\_busy](/appendixes/contrib/dblink/contrib-dblink-is-busy.md) — checks if connection is busy with an async query

[dblink\_get\_notify](/appendixes/contrib/dblink/contrib-dblink-get-notify.md) — retrieve async notifications on a connection

[dblink\_get\_result](/appendixes/contrib/dblink/contrib-dblink-get-result.md) — gets an async query result

[dblink\_cancel\_query](/appendixes/contrib/dblink/contrib-dblink-cancel-query.md) — cancels any active query on the named connection

[dblink\_get\_pkey](/appendixes/contrib/dblink/contrib-dblink-get-pkey.md) — returns the positions and field names of a relation's primary key fields

[dblink\_build\_sql\_insert](/appendixes/contrib/dblink/contrib-dblink-build-sql-insert.md) — builds an INSERT statement using a local tuple, replacing the primary key field values with alternative supplied values

[dblink\_build\_sql\_delete](/appendixes/contrib/dblink/contrib-dblink-build-sql-delete.md) — builds a DELETE statement using supplied values for primary key field values

[dblink\_build\_sql\_update](/appendixes/contrib/dblink/contrib-dblink-build-sql-update.md) — builds an UPDATE statement using a local tuple, replacing the primary key field values with alternative supplied values

`dblink` is a module that supports connections to other PostgreSQL databases from within a database session.

`dblink` can report the following wait events under the wait event type `Extension`.

`DblinkConnect` : Waiting to establish a connection to a remote server.

`DblinkGetConnect` : Waiting to establish a connection to a remote server when it could not be found in the list of already-opened connections.

`DblinkGetResult` : Waiting to receive the results of a query from a remote server.

See also [postgres\_fdw](/appendixes/contrib/postgres-fdw.md), which provides roughly the same functionality using a more modern and standards-compliant infrastructure.

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/dblink.html)（英文原文，待翻譯）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.postgresql.tw/appendixes/contrib/dblink.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
