ClickHouse/docs/en/sql-reference/statements/alter/user.md
Ivan Blinkov ffe2cecb1b
[docs] split the ALTER article (#12502)
* initial split

* initial adjust links

* make en buildable

* re-normalize
2020-07-15 00:02:41 +03:00

1.2 KiB
Raw Blame History

toc_priority toc_title
45 USER

ALTER USER

Changes ClickHouse user accounts.

Syntax:

ALTER USER [IF EXISTS] name [ON CLUSTER cluster_name]
    [RENAME TO new_name]
    [IDENTIFIED [WITH {PLAINTEXT_PASSWORD|SHA256_PASSWORD|DOUBLE_SHA1_PASSWORD}] BY {'password'|'hash'}]
    [[ADD|DROP] HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE]
    [DEFAULT ROLE role [,...] | ALL | ALL EXCEPT role [,...] ]
    [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:

ALTER USER user DEFAULT ROLE role1, role2

If roles arent previously assigned to a user, ClickHouse throws an exception.

Set all the assigned roles to default:

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:

ALTER USER user DEFAULT ROLE ALL EXCEPT role1, role2