DROP USER

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

New in v1.1: The DROP USER statement removes one or more SQL users.

Tip:
You can also use the cockroach user rm command to remove users.
Warning:
Removing a user does not remove that user's privileges. Therefore, to prevent a future user with an identical username from inheriting an old user's privileges, it's important to revoke a user's privileges before or after removing the user.

Required Privileges

The user must have the DELETE privilege on the system.users table.

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

In this example, we first check a user's privileges. We 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