The DROP ROLE statement removes one or more SQL roles.
New in v20.1 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
adminrole cannot be dropped, androotmust always be a member ofadmin. - A role cannot be dropped if it has privileges. Use
REVOKEto remove privileges.
Required privileges
Roles can only be dropped by super users, i.e., members of the admin role.
New in v20.1: To drop other non-admin roles, the role must have the CREATEROLE parameter set.
Synopsis
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 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.
> SHOW GRANTS ON documents FOR dev_ops;
+------------+--------+-----------+---------+------------+
| Database | Schema | Table | User | Privileges |
+------------+--------+-----------+---------+------------+
| jsonb_test | public | documents | dev_ops | INSERT |
+------------+--------+-----------+---------+------------+
> REVOKE INSERT ON documents FROM dev_ops;
> DROP ROLE dev_ops;
DROP ROLE 1