> 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/internals/views/view-pg-hba-file-rules.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 53.10. pg\_hba\_file\_rules \#

### 53.10. `pg_hba_file_rules` [#](#view-pg-hba-file-rules) <a href="#view-pg-hba-file-rules" id="view-pg-hba-file-rules"></a>

檢視表 `pg_hba_file_rules` 提供用戶端認證設定檔 [`pg_hba.conf`](https://docs.postgresql.tw/19/server-administration/client-authentication/auth-pg-hba-conf.md) 內容的摘要。檔案中每一個非空白、非註解的行，都會在此檢視表中以一個資料列呈現，並附有註記說明該規則是否能成功套用。

此檢視表可以協助檢查認證設定檔中預計進行的變更是否可行，或用於診斷先前的失敗。請注意，此檢視表回報的是檔案的*目前*內容，而不是伺服器最後載入的內容。

預設情況下，只有超級使用者可以讀取 `pg_hba_file_rules` 檢視表。

#### 表 53.10. `pg_hba_file_rules` 欄位 [#](#view-pg-hba-file-rules-columns) <a href="#view-pg-hba-file-rules-columns" id="view-pg-hba-file-rules-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                              |
| ------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>rule\_number</code> <code>int4</code></p><p>若此規則有效，則為此規則的編號，否則為 <code>NULL</code>。它表示在認證期間，直到找到相符的規則為止，各規則被檢查的順序。</p>                    |
| <p><code>file\_name</code> <code>text</code></p><p>包含此規則的檔案名稱</p>                                                                                 |
| <p><code>line\_number</code> <code>int4</code></p><p>此規則在 <code>file\_name</code> 中的行號</p>                                                        |
| <p><code>type</code> <code>text</code></p><p>連線類型</p>                                                                                             |
| <p><code>database</code> <code>text\[]</code></p><p>此規則所適用的資料庫名稱清單</p>                                                                            |
| <p><code>user\_name</code> <code>text\[]</code></p><p>此規則所適用的使用者與群組名稱清單</p>                                                                       |
| <p><code>address</code> <code>text</code></p><p>主機名稱或 IP 位址，或是 <code>all</code>、<code>samehost</code>、<code>samenet</code> 其中之一；若為本機連線則為 null</p> |
| <p><code>netmask</code> <code>text</code></p><p>IP 位址遮罩；若不適用則為 null</p>                                                                           |
| <p><code>auth\_method</code> <code>text</code></p><p>認證方法</p>                                                                                     |
| <p><code>options</code> <code>text\[]</code></p><p>為認證方法指定的選項（若有）</p>                                                                             |
| <p><code>error</code> <code>text</code></p><p>若不為 null，則為說明此行為何無法處理的錯誤訊息</p>                                                                      |

<br>

通常，反映錯誤項目的資料列只會在 `line_number` 與 `error` 欄位中有值。

關於用戶端認證設定的更多資訊，請參閱[第 20 章](https://docs.postgresql.tw/19/server-administration/client-authentication.md)。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/view-pg-hba-file-rules.html)（原文版本：18.6；核對日期：2026-10-09）


---

# 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/internals/views/view-pg-hba-file-rules.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.
