Postgresql 中文操作指南
Description
DROP ROLE 删除指定的角色。若要删除超级用户角色,您自己必须是超级用户;要删除非超级用户角色,您必须拥有 CREATEROLE 权限,并且在该角色上已被授予 ADMIN OPTION 。
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.
如果在群集的任何数据库中仍有引用角色,则无法删除该角色;如果确实如此,将会引发一个错误。在删除角色之前,您必须删除其拥有的所有对象(或重新分配其所有权),并吊销授予角色在其他对象上的任何权限。 REASSIGN OWNED 和 DROP OWNED 命令可用于此目的;有关更多讨论,请参见 Section 22.4 。
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 and DROP OWNED commands can be useful for this purpose; see Section 22.4 for more discussion.
但是,不必删除涉及该角色的角色成员资格; DROP ROLE 会自动吊销目标角色在其他角色中的任何成员资格,以及目标角色中其他角色的成员资格。其他角色不会被删除或受到其他影响。
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.
-
Compatibility
SQL 标准定义了 DROP ROLE ,但它一次只允许废弃一个角色,并且指定了不同于 PostgreSQL 使用的权限要求。
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.