DROP ROLE (Enterprise)

The DROP ROLE statement removes one or more SQL roles.

Note:
DROP ROLE is an enterprise-only feature.

Considerations

  • The admin role cannot be dropped, and root must always be a member of admin.
  • 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

DROPROLEIFEXISTSname

Parameters

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

  1. > SHOW GRANTS ON documents FOR dev_ops;
  1. +------------+--------+-----------+---------+------------+
  2. | Database | Schema | Table | User | Privileges |
  3. +------------+--------+-----------+---------+------------+
  4. | jsonb_test | public | documents | dev_ops | INSERT |
  5. +------------+--------+-----------+---------+------------+
  1. > REVOKE INSERT ON documents FROM dev_ops;

Note:
All of a role's privileges must be revoked before the role can be dropped.

  1. > DROP ROLE dev_ops;
  1. DROP ROLE 1

See also

Was this page helpful?
YesNo