> 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/19/appendixes/contrib/dblink.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# F.11. dblink — 連線至其他 PostgreSQL 資料庫 \#

### F.11. dblink — 連線至其他 PostgreSQL 資料庫 [#](#dblink) <a href="#dblink" id="dblink"></a>

[dblink\_connect](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-connect.md) — 開啟遠端資料庫的持續連線

[dblink\_connect\_u](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-connect-u.md) — 以不安全的方式開啟遠端資料庫的持續連線

[dblink\_disconnect](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-disconnect.md) — 關閉遠端資料庫的持續連線

[dblink](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-function.md) — 在遠端資料庫執行查詢

[dblink\_exec](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-exec.md) — 在遠端資料庫執行命令

[dblink\_open](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-open.md) — 在遠端資料庫開啟游標

[dblink\_fetch](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-fetch.md) — 從遠端資料庫的已開啟游標傳回資料列

[dblink\_close](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-close.md) — 關閉遠端資料庫的游標

[dblink\_get\_connections](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-get-connections.md) — 傳回所有已開啟具名 dblink 連線的名稱

[dblink\_error\_message](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-error-message.md) — 取得具名連線上的最新錯誤訊息

[dblink\_send\_query](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-send-query.md) — 將非同步查詢傳送至遠端資料庫

[dblink\_is\_busy](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-is-busy.md) — 檢查連線是否忙於處理非同步查詢

[dblink\_get\_notify](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-get-notify.md) — 擷取連線上的非同步通知

[dblink\_get\_result](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-get-result.md) — 取得非同步查詢結果

[dblink\_cancel\_query](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-cancel-query.md) — 取消具名連線上的任何作用中查詢

[dblink\_get\_pkey](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-get-pkey.md) — 傳回關聯主鍵欄位的位置及欄位名稱

[dblink\_build\_sql\_insert](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-build-sql-insert.md) — 使用本端 tuple 建立 INSERT 陳述式，並以提供的替代值取代主鍵欄位值

[dblink\_build\_sql\_delete](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-build-sql-delete.md) — 使用提供的主鍵欄位值建立 DELETE 陳述式

[dblink\_build\_sql\_update](https://docs.postgresql.tw/19/appendixes/contrib/dblink/contrib-dblink-build-sql-update.md) — 使用本端 tuple 建立 UPDATE 陳述式，並以提供的替代值取代主鍵欄位值

`dblink` 是支援從資料庫 session 內連線至其他 PostgreSQL 資料庫的模組。

`dblink` 可在 `Extension` 等待事件類型下回報下列等待事件。

`DblinkConnect` : 等待建立至遠端伺服器的連線。

`DblinkGetConnect` : 在已開啟連線清單中找不到連線時，等待建立至遠端伺服器的連線。

`DblinkGetResult` : 等待接收遠端伺服器傳回的查詢結果。

另請參閱 [postgres\_fdw](https://docs.postgresql.tw/19/appendixes/contrib/postgres-fdw.md)，它以較現代且符合標準的基礎架構提供 大致相同的功能。

***

原文：[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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
