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

# 53.22. pg\_rules \#

### 53.22. `pg_rules` [#](#view-pg-rules) <a href="#view-pg-rules" id="view-pg-rules"></a>

檢視表 `pg_rules` 提供對查詢重寫規則之實用資訊的存取。

#### 表 53.22. `pg_rules` 欄位 [#](#view-pg-rules-columns) <a href="#view-pg-rules-columns" id="view-pg-rules-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                           |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>schemaname</code> <code>name</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-namespace.md"><code>pg\_namespace</code></a>.<code>nspname</code>）</p><p>包含資料表之綱要的名稱</p> |
| <p><code>tablename</code> <code>name</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a>.<code>relname</code>）</p><p>此規則所屬之資料表的名稱</p>         |
| <p><code>rulename</code> <code>name</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-rewrite.md"><code>pg\_rewrite</code></a>.<code>rulename</code>）</p><p>規則名稱</p>             |
| <p><code>definition</code> <code>text</code></p><p>規則定義（重建出的建立命令）</p>                                                                                                                                          |

<br>

檢視表 `pg_rules` 不包含檢視表與具體化檢視表的 `ON SELECT` 規則；這些規則可在 [`pg_views`](https://docs.postgresql.tw/19/internals/views/view-pg-views.md) 與 [`pg_matviews`](https://docs.postgresql.tw/19/internals/views/view-pg-matviews.md) 中查看。

***

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


---

# 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-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.
