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

# 53.21. pg\_roles \#

### 53.21. `pg_roles` [#](#view-pg-roles) <a href="#view-pg-roles" id="view-pg-roles"></a>

檢視表 `pg_roles` 可用來存取資料庫角色的相關資訊。它只是 [`pg_authid`](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-authid.md) 的一個公開可讀的檢視表，並會遮蔽密碼欄位（一律顯示為 \*\*\*\*\*\*\*\*）。

#### 表 53.21. `pg_roles` 欄位 [#](#view-pg-roles-columns) <a href="#view-pg-roles-columns" id="view-pg-roles-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                    |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>rolname</code> <code>name</code></p><p>角色名稱</p>                                                                                                                                |
| <p><code>rolsuper</code> <code>bool</code></p><p>角色具有超級使用者權限</p>                                                                                                                        |
| <p><code>rolinherit</code> <code>bool</code></p><p>角色會自動繼承其身為成員之角色的權限</p>                                                                                                               |
| <p><code>rolcreaterole</code> <code>bool</code></p><p>角色可以建立更多角色</p>                                                                                                                    |
| <p><code>rolcreatedb</code> <code>bool</code></p><p>角色可以建立資料庫</p>                                                                                                                       |
| <p><code>rolcanlogin</code> <code>bool</code></p><p>角色可以登入。也就是說，此角色可以作為初始的工作階段授權識別碼</p>                                                                                                 |
| <p><code>rolreplication</code> <code>bool</code></p><p>角色是複寫角色。複寫角色可以發起複寫連線，並可建立與移除複寫插槽。</p>                                                                                            |
| <p><code>rolconnlimit</code> <code>int4</code></p><p>對於可以登入的角色，此欄位設定該角色可建立的最大並行連線數。-1 表示沒有限制。</p>                                                                                       |
| <p><code>rolpassword</code> <code>text</code></p><p>不是密碼（讀取時一律顯示為 <code>\*\*\*\*\*\*\*\*</code>）</p>                                                                                    |
| <p><code>rolvaliduntil</code> <code>timestamptz</code></p><p>密碼到期時間（僅用於密碼認證）；若無到期時間則為 null</p>                                                                                          |
| <p><code>rolbypassrls</code> <code>bool</code></p><p>角色會略過所有資料列層級安全性政策，更多資訊請參閱<a href="https://docs.postgresql.tw/19/the-sql-language/ddl/ddl-rowsecurity.md">第 5.9 節</a>。</p>          |
| <p><code>rolconfig</code> <code>text\[]</code></p><p>角色專屬的執行期設定變數預設值</p>                                                                                                                |
| <p><code>oid</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>角色的 ID</p> |

<br>

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/view-pg-roles.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-roles.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.
