2020-07-14 21:02:41 +00:00
|
|
|
|
---
|
|
|
|
|
toc_priority: 45
|
|
|
|
|
toc_title: USER
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# ALTER USER {#alter-user-statement}
|
|
|
|
|
|
|
|
|
|
Changes ClickHouse user accounts.
|
|
|
|
|
|
|
|
|
|
Syntax:
|
|
|
|
|
|
|
|
|
|
``` sql
|
2021-01-26 22:40:14 +00:00
|
|
|
|
ALTER USER [IF EXISTS] name1 [ON CLUSTER cluster_name1] [RENAME TO new_name1]
|
2021-01-23 13:14:01 +00:00
|
|
|
|
[, name2 [ON CLUSTER cluster_name2] [RENAME TO new_name2] ...]
|
2021-03-11 20:41:10 +00:00
|
|
|
|
[NOT IDENTIFIED | IDENTIFIED {[WITH {no_password | plaintext_password | sha256_password | sha256_hash | double_sha1_password | double_sha1_hash}] BY {'password' | 'hash'}} | {WITH ldap SERVER 'server_name'} | {WITH kerberos [REALM 'realm']}]
|
|
|
|
|
[[ADD | DROP] HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE]
|
2020-07-14 21:02:41 +00:00
|
|
|
|
[DEFAULT ROLE role [,...] | ALL | ALL EXCEPT role [,...] ]
|
2021-03-11 20:41:10 +00:00
|
|
|
|
[SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY | WRITABLE] | PROFILE 'profile_name'] [,...]
|
2020-07-14 21:02:41 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
To use `ALTER USER` you must have the [ALTER USER](../../../sql-reference/statements/grant.md#grant-access-management) privilege.
|
|
|
|
|
|
|
|
|
|
## Examples {#alter-user-examples}
|
|
|
|
|
|
|
|
|
|
Set assigned roles as default:
|
|
|
|
|
|
|
|
|
|
``` sql
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
``` sql
|
|
|
|
|
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`:
|
|
|
|
|
|
|
|
|
|
``` sql
|
|
|
|
|
ALTER USER user DEFAULT ROLE ALL EXCEPT role1, role2
|
|
|
|
|
```
|