On this page
Warning:
As of October 4, 2019, CockroachDB v2.0 is no longer supported. For more details, refer to the Release Support Policy.
New in v2.0: The DROP ROLE
statement removes one or more SQL roles.
Considerations
- The
admin
role cannot be dropped, androot
must always be a member ofadmin
. - A role cannot be dropped if it has privileges. Use
REVOKE
to remove privileges.
Required Privileges
Roles can only be dropped by super users, i.e., members of the admin
role.
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;
Note:
All of a role's privileges must be revoked before the role can be dropped.> DROP ROLE dev_ops;
DROP ROLE 1