Skip to main content
The DROP USER removes one or more SQL users. You can use the keywords ROLE and USER interchangeably. DROP USER is an alias for .
The “ statement performs a schema change. For more information about how online schema changes work in CockroachDB, see .

Consideration

Users that (such as databases, tables, schemas, and types) cannot be dropped until the .

Required privileges

Non-admin users cannot drop admin users. To drop non-admin users, the user must be a member of the admin role or have the parameter set.

Synopsis

See .

Parameters

ParameterDescription
user_nameThe name of the user to remove. To remove multiple users, use a comma-separate list of usernames.

You can use 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.
You can test that dropping the user will fail unless all privileges are revoked (including ). Issue the following statement to revoke a subset of the user’s privileges:
If you attempt to drop a user with privileges remaining, you will encounter an error like the following:
To see what privileges the user still has remaining on the table, issue the following statement:
To drop the user you must revoke all of the user’s remaining privileges:
Now dropping the user should succeed:

See also