跳至主要内容

ALTER QUOTA

更改配额。

语法

ALTER QUOTA [IF EXISTS] name [ON CLUSTER cluster_name]
[RENAME TO new_name]
[KEYED BY {user_name | ip_address | client_key | client_key,user_name | client_key,ip_address} | NOT KEYED]
[FOR [RANDOMIZED] INTERVAL number {second | minute | hour | day | week | month | quarter | year}
{MAX { {queries | query_selects | query_inserts | errors | result_rows | result_bytes | read_rows | read_bytes | execution_time} = number } [,...] |
NO LIMITS | TRACKING ONLY} [,...]]
[TO {role [,...] | ALL | ALL EXCEPT role [,...]}]

user_nameip_addressclient_keyclient_key, user_nameclient_key, ip_address 对应于 system.quotas 表中的字段。

参数 queriesquery_selects、'query_inserts'、errorsresult_rowsresult_bytesread_rowsread_bytesexecution_time 对应于 system.quotas_usage 表中的字段。

ON CLUSTER 子句允许在集群上创建配额,请参阅 分布式 DDL

示例

将当前用户的最大查询数限制为 123 个查询,约束时间为 15 个月

ALTER QUOTA IF EXISTS qA FOR INTERVAL 15 month MAX queries = 123 TO CURRENT_USER;

对于默认用户,将最大执行时间限制为半秒,时间段为 30 分钟;将最大查询数限制为 321,最大错误数限制为 10,时间段为 5 个季度

ALTER QUOTA IF EXISTS qB FOR INTERVAL 30 minute MAX execution_time = 0.5, FOR INTERVAL 5 quarter MAX queries = 321, errors = 10 TO default;