> 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/reference/sql-commands/sql-droprole.md).

# DROP ROLE

### DROP ROLE

DROP ROLE — remove a database role

### Synopsis

```

DROP ROLE [ IF EXISTS ] name [, ...]
```

### Description

`DROP ROLE` removes the specified role(s). To drop a superuser role, you must be a superuser yourself; to drop non-superuser roles, you must have `CREATEROLE` privilege and have been granted `ADMIN OPTION` on the role.

A role cannot be removed if it is still referenced in any database of the cluster; an error will be raised if so. Before dropping the role, you must drop all the objects it owns (or reassign their ownership) and revoke any privileges the role has been granted on other objects. The [`REASSIGN OWNED`](/reference/sql-commands/sql-reassign-owned.md) and [`DROP OWNED`](/reference/sql-commands/sql-drop-owned.md) commands can be useful for this purpose; see [Section 21.4](/server-administration/user-manag/role-removal.md) for more discussion.

However, it is not necessary to remove role memberships involving the role; `DROP ROLE` automatically revokes any memberships of the target role in other roles, and of other roles in the target role. The other roles are not dropped nor otherwise affected.

### Parameters

`IF EXISTS` : Do not throw an error if the role does not exist. A notice is issued in this case.

*`name`* : The name of the role to remove.

### Notes

PostgreSQL includes a program [dropuser](/reference/reference-client/app-dropuser.md) that has the same functionality as this command (in fact, it calls this command) but can be run from the command shell.

### Examples

To drop a role:

```

DROP ROLE jonathan;
```

### Compatibility

The SQL standard defines `DROP ROLE`, but it allows only one role to be dropped at a time, and it specifies different privilege requirements than PostgreSQL uses.

### See Also

[CREATE ROLE](/reference/sql-commands/sql-createrole.md), [ALTER ROLE](/reference/sql-commands/sql-alterrole.md), [SET ROLE](/reference/sql-commands/sql-set-role.md)

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/sql-droprole.html)（英文原文，待翻譯）


---

# 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 dynamically by asking a question.

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

```
GET https://docs.postgresql.tw/reference/sql-commands/sql-droprole.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
