# 22. 資料庫角色

PostgreSQL 使用角色的概念來管理資料庫的存取權限。角色可以被視為資料庫使用者或一個資料庫使用者群組，具體取決於角色的設定方式。角色可以擁有資料庫物件（例如資料表和函數），並可以將這些物件的權限分配給其他角色，以控制誰可以存取哪些物件。此外，也可以將角色中的成員身份授予另一個角色，使得成員角色能夠使用分配給其他角色的權限。

角色的概念包含「使用者」和「群組」的概念。在 8.1 版之前的 PostgreSQL中，使用者和群組是不同種類的實體，但現在只有角色。任何角色都可以充當使用者、群組或兩者兼具。

本章介紹如何建立和管理角色。有關角色權限對各種資料庫物件的影響和更多訊息可以在[ 5.7 節](https://docs.postgresql.tw/15/the-sql-language/ddl/privileges)中找到。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.postgresql.tw/15/server-administration/database-roles.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
