RBAC in ClickHouse lets you manage fine-grained privileges with roles and users, improving security and auditability.
RBAC (Role-Based Access Control) centralizes privilege management. Instead of granting rights to every user, you grant them to roles, then assign roles to users. This reduces admin work and audit complexity.
Run CREATE ROLE role_name
. Roles are metadata objects that hold privileges but cannot log in. Example: CREATE ROLE analytics_reader;
Use GRANT privilege ON db.table TO role
. You can grant multiple privileges at once: GRANT SELECT ON ecommerce.Customers TO analytics_reader;
Users authenticate to ClickHouse. Create with CREATE USER
, then GRANT role TO user
. Example: CREATE USER alice IDENTIFIED BY 's3cr3t'; GRANT analytics_reader TO alice;
Query system tables: SELECT * FROM system.roles;
for roles, and SHOW GRANTS FOR role analytics_reader;
for role privileges.
Create roles around job functions (reader, writer). Grant the minimum required privileges. Use role inheritance for tiered access. Review system.grants
regularly.
Granting privileges directly to users bypasses RBAC’s benefit. Forgetting to set SET DEFAULT ROLE
can block user access after login.
Yes. Grant one role to another: GRANT junior_reader TO senior_reader;
. The senior role inherits all junior privileges.
Run REVOKE privilege ON db.table FROM role
. Example: REVOKE INSERT ON ecommerce.Orders FROM analytics_writer;
Yes. RBAC works in both open-source and ClickHouse Cloud editions starting from version 20.4.