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

# 第 21 章 資料庫角色

**目錄**

[21.1. 資料庫角色](https://docs.postgresql.tw/19/server-administration/user-manag/database-roles.md)

[21.2. 角色屬性](https://docs.postgresql.tw/19/server-administration/user-manag/role-attributes.md)

[21.3. 角色成員資格](https://docs.postgresql.tw/19/server-administration/user-manag/role-membership.md)

[21.4. 移除角色](https://docs.postgresql.tw/19/server-administration/user-manag/role-removal.md)

[21.5. 預先定義角色](https://docs.postgresql.tw/19/server-administration/user-manag/predefined-roles.md)

[21.6. 函式安全性](https://docs.postgresql.tw/19/server-administration/user-manag/perm-functions.md)

PostgreSQL 使用*角色*概念管理資料庫存取權限。角色可依設定視為資料庫使用者或資料庫使用者群組。角色可擁有資料庫物件（例如資料表與函式），並將這些物件的權限授與其他角色，以控制誰可存取哪些物件。此外，可將角色的*成員資格*授與另一角色，讓成員角色使用指派給另一角色的權限。

角色概念涵蓋「使用者」與「群組」概念。在 PostgreSQL 8.1 之前，使用者與群組是不同類型的實體；現在則只有角色。任何角色都可作為使用者、群組或兩者。

本章說明如何建立與管理角色。角色權限對各種資料庫物件的影響，請參閱[第 5.8 節](https://docs.postgresql.tw/19/the-sql-language/ddl/ddl-priv.md)。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/user-manag.html)（原文版本：18.6；核對日期：2026-09-11）


---

# 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/server-administration/user-manag.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.
