Updated on 2024-12-24 GMT+08:00

Using Role Management Commands

This section describes how to use basic syntax and SQL statements to manage roles.

  1. Creating a role ( role_name indicates the name of the role to be created)
    CREATE role IF NOT EXISTS 'role_name' ON CLUSTER default_cluster;
  2. Granting permissions to a role
    • Granting all creation (database and table) permissions
      GRANT CREATE ON *.* TO role1 ON CLUSTER default_cluster;
    • Granting the permission to create tables in the test_db database
      GRANT CREATE TABLE ON test_db.* TO role1;
    • Granting the permission to delete all databases and tables
      GRANT DROP ON test_db.* TO role1;
  3. Deleting a role
    DROP ROLE 'role_name' ON CLUSTER default_cluster;
  4. Querying the permissions and roles of a user
    • Querying permissions of a user
      show grants for all;
    • Querying permissions of a role
      show grants for role1;