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

# 36.1. 擴充性的運作方式 \#

### 36.1. 擴充性的運作方式 [#](#extend-how) <a href="#extend-how" id="extend-how"></a>

PostgreSQL 之所以可以擴充，是因為它的運作是以目錄驅動的。如果你熟悉標準的關聯式資料庫系統，就會知道它們會把資料庫、資料表、欄位等等的資訊，儲存在一般稱為系統目錄的地方（有些系統把它叫做資料字典）。這些目錄在使用者看來就跟其他資料表一樣，但資料庫管理系統會把它內部的簿記資訊存放在裡面。PostgreSQL 與標準關聯式資料庫系統之間的一項關鍵差異，在於 PostgreSQL 在它的目錄中儲存了更多資訊：不只是資料表與欄位的資訊，還包括資料型別、函式、存取方法等等的資訊。這些資料表可以由使用者修改，而由於 PostgreSQL 的運作是以這些資料表為基礎，這就表示 PostgreSQL 可以由使用者來擴充。相較之下，傳統的資料庫系統只能藉由變更原始碼中寫死的常式，或是載入由資料庫管理系統廠商特別撰寫的模組，才能加以擴充。

此外，PostgreSQL 伺服器還可以透過動態載入，把使用者自行撰寫的程式碼納入自身之中。也就是說，使用者可以指定一個目的碼檔案（例如共享程式庫），用來實作新的型別或函式，而 PostgreSQL 會在需要時載入它。以 SQL 撰寫的程式碼，要加入伺服器更是輕而易舉。這種可以「即時」修改其運作方式的能力，使得 PostgreSQL 獨具優勢，特別適合用來快速開發新應用程式與儲存結構的原型。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/extend-how.html)（原文版本：18.6；核對日期：2026-09-22）


---

# 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/server-programming/extend/extend-how.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.
