user_name, ip_address, forwarded_ip_address, client_key, client_key, user_name, client_key, ip_address, and normalized_query_hash correspond to the fields in the system.quotas table.
IPV4_PREFIX_BITS and IPV6_PREFIX_BITS options can only be used when KEYED BY is ip_address or forwarded_ip_address. They correspond to the field in the system.quotas table.
Parameters queries, query_selects, query_inserts, errors, result_rows, result_bytes, read_rows, read_bytes, execution_time, written_bytes, written_rows, failed_sequential_authentications, queries_per_normalized_hash correspond to the fields in the system.quotas_usage table.
In addition to the predefined resource types above, a limit can be set on any profile event (see the system.events table) by its name, for example MAX S3GetObject = 1000. Profile events are accounted once per query, at the moment the query finishes (successfully or with an error): a query that crosses the limit is still allowed to finish, and the subsequent queries are rejected until the interval ends. The current consumption is reported in the profile_events column of the system.quotas_usage table.
ON CLUSTER clause allows creating quotas on a cluster, see Distributed DDL.
CREATE QUOTA requires the CREATE QUOTA privilege. OR REPLACE throws away an existing quota of the same name, including which roles it applies to, so it additionally requires the DROP QUOTA privilege. The DROP QUOTA privilege is required whether or not the quota already exists, so the statement cannot be used to find out which quotas exist.
Examples
Limit the maximum number of queries for the current user with 123 queries in 15 months constraint:
S3GetObject requests and the number of failed queries per day using profile events: