DROP USER

On this page Carat arrow pointing down
Warning:
As of November 12, 2021, CockroachDB v20.1 is no longer supported. For more details, refer to the Release Support Policy.

The DROP USER statement removes one or more SQL users.

Note:

New in v20.1: Since the keywords ROLE and USER can now be used interchangeably in SQL statements for enhanced Postgres compatibility, DROP USER is now an alias for DROP ROLE.

Required privileges

New in v20.1: To drop other non-admin users, the user must have the CREATEROLE parameter set.

Synopsis

DROP USER IF EXISTS user_name ,

Parameters

Parameter Description
user_name The username of the user to remove. To remove multiple users, use a comma-separate list of usernames.

You can use SHOW USERS to find usernames.

Example

All of a user's privileges must be revoked before the user can be dropped.

In this example, first check a user's privileges. Then, revoke the user's privileges before removing the user.

icon/buttons/copy
> SHOW GRANTS ON test.customers FOR mroach;
+-----------+--------+------------+
|   Table   |  User  | Privileges |
+-----------+--------+------------+
| customers | mroach | CREATE     |
| customers | mroach | INSERT     |
| customers | mroach | UPDATE     |
+-----------+--------+------------+
(3 rows)
icon/buttons/copy
> REVOKE CREATE,INSERT,UPDATE ON test.customers FROM mroach;
icon/buttons/copy
> DROP USER mroach;

See also


Yes No
On this page

Yes No