ALTER USER

Changes ClickHouse user accounts.

Syntax:

  1. ALTER USER [IF EXISTS] name [ON CLUSTER cluster_name]
  2. [RENAME TO new_name]
  3. [IDENTIFIED [WITH {PLAINTEXT_PASSWORD|SHA256_PASSWORD|DOUBLE_SHA1_PASSWORD}] BY {'password'|'hash'}]
  4. [[ADD|DROP] HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE]
  5. [DEFAULT ROLE role [,...] | ALL | ALL EXCEPT role [,...] ]
  6. [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...]

To use ALTER USER you must have the ALTER USER privilege.

Examples

Set assigned roles as default:

  1. ALTER USER user DEFAULT ROLE role1, role2

If roles aren’t previously assigned to a user, ClickHouse throws an exception.

Set all the assigned roles to default:

  1. ALTER USER user DEFAULT ROLE ALL

If a role is assigned to a user in the future, it will become default automatically.

Set all the assigned roles to default, excepting role1 and role2:

  1. ALTER USER user DEFAULT ROLE ALL EXCEPT role1, role2