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

# 52.38. pg\_policy \#

### 52.38. `pg_policy` [#](#catalog-pg-policy) <a href="#catalog-pg-policy" id="catalog-pg-policy"></a>

目錄 `pg_policy` 儲存資料表的資料列層級安全性政策。一個政策包含：它所適用的命令種類（可能是所有命令）、它所適用的角色、要作為安全屏障條件加入包含該資料表之查詢的運算式，以及要作為 `WITH CHECK` 選項加入嘗試在該資料表新增紀錄之查詢的運算式。

#### 表 52.38. `pg_policy` 欄位 [#](#catalog-pg-policy-columns) <a href="#catalog-pg-policy-columns" id="catalog-pg-policy-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>oid</code> <code>oid</code></p><p>資料列識別碼</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| <p><code>polname</code> <code>name</code></p><p>政策名稱</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| <p><code>polrelid</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a>.<code>oid</code>）</p><p>此政策所適用的資料表</p>                                                                                                                                                                                                                                                                                                                                     |
| <p><code>polcmd</code> <code>char</code></p><p>此政策所套用的命令類型： <code>r</code> 表示 <a href="https://docs.postgresql.tw/19/reference/sql-commands/sql-select.md">SELECT</a>、 <code>a</code> 表示 <a href="https://docs.postgresql.tw/19/reference/sql-commands/sql-insert.md">INSERT</a>、 <code>w</code> 表示 <a href="https://docs.postgresql.tw/19/reference/sql-commands/sql-update.md">UPDATE</a>、 <code>d</code> 表示 <a href="https://docs.postgresql.tw/19/reference/sql-commands/sql-delete.md">DELETE</a>， 或 <code>\*</code> 表示全部</p> |
| <p><code>polpermissive</code> <code>bool</code></p><p>此政策是寬鬆政策還是限制性政策？</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| <p><code>polroles</code> <code>oid\[]</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-authid.md"><code>pg\_authid</code></a>.<code>oid</code>）</p><p>此政策所套用的角色； 零表示 <code>PUBLIC</code> （且通常在陣列中單獨出現）</p>                                                                                                                                                                                                                                                                                          |
| <p><code>polqual</code> <code>pg\_node\_tree</code></p><p>要加入使用該資料表之查詢的安全屏障條件中的運算式樹</p>                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| <p><code>polwithcheck</code> <code>pg\_node\_tree</code></p><p>要加入嘗試在該資料表新增資料列之查詢的 WITH CHECK 條件中的運算式樹</p>                                                                                                                                                                                                                                                                                                                                                                                                                         |

<br>

#### 注意

儲存在 `pg_policy` 中的政策，只有在其資料表的 [`pg_class`](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md).`relrowsecurity` 已設定時才會套用。

***

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


---

# 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/catalogs/catalog-pg-policy.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.
