ALTER QUOTA

Changes quotas.

Syntax:

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

Keys user_name, ip_address, client_key, client_key, user_name and client_key, ip_address correspond to the fields in the system.quotas table.

Parameters queries, query_selects, ‘query_inserts’, errors,result_rows,result_bytes,read_rows,read_bytes,execution_time` correspond to the fields in the system.quotas_usage table.

ON CLUSTER clause allows creating quotas on a cluster, see Distributed DDL.

Examples

Limit the maximum number of queries for the current user with 123 queries in 15 months constraint:

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

For the default user limit the maximum execution time with half a second in 30 minutes, and limit the maximum number of queries with 321 and the maximum number of errors with 10 in 5 quaters:

  1. 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;