DROP USER

The DROP USER statement removes one or more SQL users.

Tip:
You can also use the cockroach user rm command to remove users.

Required privileges

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

Synopsis

DROPUSERIFEXISTSuser_name,

Parameters

ParameterDescription
user_nameThe 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.

  1. > SHOW GRANTS ON test.customers FOR mroach;
  1. +-----------+--------+------------+
  2. | Table | User | Privileges |
  3. +-----------+--------+------------+
  4. | customers | mroach | CREATE |
  5. | customers | mroach | INSERT |
  6. | customers | mroach | UPDATE |
  7. +-----------+--------+------------+
  8. (3 rows)
  1. > REVOKE CREATE,INSERT,UPDATE ON test.customers FROM mroach;
  1. > DROP USER mroach;

See also

Was this page helpful?
YesNo