DROP ROLE

On this page Carat arrow pointing down
Warning:
CockroachDB v20.2 is no longer supported as of May 10, 2022. For more details, refer to the Release Support Policy.

The DROP ROLE statement removes one or more SQL roles.

Note:

DROP ROLE is no longer an Enterprise feature and is now freely available in the core version of CockroachDB. Also, since the keywords ROLE and USER can now be used interchangeably in SQL statements for enhanced Postgres compatibility, DROP ROLE is now an alias for DROP USER.

Considerations

  • The admin role cannot be dropped, and root must always be a member of admin.
  • A role cannot be dropped if it has privileges. Use REVOKE to remove privileges.
  • Roles that own objects (such as databases, tables, schemas, and types) cannot be dropped until the ownership is transferred to another role.

Required privileges

Non-admin roles cannot drop admin roles. To drop non-admin roles, the role must be a member of the admin role or have the CREATEROLE parameter set.

Synopsis

DROP ROLE IF EXISTS name
## Parameters Parameter | Description ------------|-------------- `name` | The name of the role to remove. To remove multiple roles, use a comma-separate list of roles.

You can use [`SHOW ROLES`](show-roles.html) to find the names of roles. ## Example In this example, first check a role's privileges. Then, revoke the role's privileges and remove the role.
icon/buttons/copy
> SHOW GRANTS ON documents FOR dev_ops;
+------------+--------+-----------+---------+------------+
|  Database  | Schema |   Table   |  User   | Privileges |
+------------+--------+-----------+---------+------------+
| jsonb_test | public | documents | dev_ops | INSERT     |
+------------+--------+-----------+---------+------------+
icon/buttons/copy
> REVOKE INSERT ON documents FROM dev_ops;
Note:
All of a role's privileges must be revoked before the role can be dropped.
icon/buttons/copy
> DROP ROLE dev_ops;

See also


Yes No
On this page

Yes No