> 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/reference/sql-commands/sql-create-access-method.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# CREATE ACCESS METHOD

### CREATE ACCESS METHOD

CREATE ACCESS METHOD — 定義新的存取方法

### 語法

```

CREATE ACCESS METHOD name
    TYPE access_method_type
    HANDLER handler_function
```

### 說明

`CREATE ACCESS METHOD` 會建立新的存取方法。

存取方法的名稱在資料庫中必須是唯一的。

只有超級使用者可以定義新的存取方法。

### 參數

*`name`* : 要建立之存取方法的名稱。

*`access_method_type`* : 此子句指定要定義的存取方法類型。 目前只支援 `TABLE` 與 `INDEX`。

*`handler_function`* : *`handler_function`* 是先前已註冊、代表該存取方法之函式的名稱（可能以綱要限定）。處理函式必須宣告為接受單一個 `internal` 型別的參數，其傳回型別則取決於存取方法的類型；對於 `TABLE` 存取方法，傳回型別必須是 `table_am_handler`，對於 `INDEX` 存取方法，則必須是 `index_am_handler`。 處理函式必須實作的 C 層級 API 依存取方法的類型而異。資料表存取方法 API 說明於[第 62 章](https://docs.postgresql.tw/19/internals/tableam.md)，索引存取方法 API 說明於[第 63 章](https://docs.postgresql.tw/19/internals/indexam.md)。

### 範例

建立索引存取方法 `heptree`，其處理函式為 `heptree_handler`：

```

CREATE ACCESS METHOD heptree TYPE INDEX HANDLER heptree_handler;
```

### 相容性

`CREATE ACCESS METHOD` 是 PostgreSQL 的擴充語法。

### 另請參閱

[DROP ACCESS METHOD](https://docs.postgresql.tw/19/reference/sql-commands/sql-drop-access-method.md), [CREATE OPERATOR CLASS](https://docs.postgresql.tw/19/reference/sql-commands/sql-createopclass.md), [CREATE OPERATOR FAMILY](https://docs.postgresql.tw/19/reference/sql-commands/sql-createopfamily.md)

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/sql-create-access-method.html)（原文版本：18.6；核對日期：2026-10-04）


---

# 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/reference/sql-commands/sql-create-access-method.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.
