Skip to main content
Activates roles for the current user.

SET DEFAULT ROLE

Sets default roles to a user. Default roles are automatically activated at user login. You can set as default only the previously granted roles. If the role isn’t granted to a user, ClickHouse throws an exception.
ON CLUSTER is accepted either right after SET DEFAULT ROLE or at the end of the query, and executes it on every host of the cluster. CURRENT_USER is resolved on the initiator before the query is distributed. SET ROLE only changes the current session and therefore takes no ON CLUSTER clause.

Examples

Set multiple default roles to a user:
Set all the granted roles as default to a user:
Purge default roles from a user:
Set all the granted roles as default except for specific roles role1 and role2:
Set default roles on every host of a cluster:
Last modified on October 3, 2026