> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-fbfa8bee.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> QUOTA に関するドキュメント

# ALTER QUOTA

QUOTA を変更します。

構文:

```sql theme={null}
ALTER QUOTA [IF EXISTS] name [ON CLUSTER cluster_name]
    [RENAME TO new_name]
    [KEYED BY {user_name | ip_address | forwarded_ip_address | client_key | client_key,user_name | client_key,ip_address | normalized_query_hash} | NOT KEYED]
    [IPV4_PREFIX_BITS number]
    [IPV6_PREFIX_BITS number]
    [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 | queries_per_normalized_hash} = number } [,...] |
        NO LIMITS | TRACKING ONLY} [,...]]
    [TO {role [,...] | ALL | ALL EXCEPT role [,...]}]
```

キー `user_name`、`ip_address`、`forwarded_ip_address`、`client_key`、`client_key, user_name`、`client_key, ip_address`、`normalized_query_hash` は、[system.quotas](/ja/reference/system-tables/quotas) テーブルのフィールドに対応します。

`IPV4_PREFIX_BITS` および `IPV6_PREFIX_BITS` オプションは、`KEYED BY` が `ip_address` または `forwarded_ip_address` の場合にのみ使用できます。これらは [system.quotas](/ja/reference/system-tables/quotas) テーブルのフィールドに対応します。

パラメータ `queries`、`query_selects`、`query_inserts`、`errors`、`result_rows`、`result_bytes`、`read_rows`、`read_bytes`、`execution_time`、`queries_per_normalized_hash` は、[system.quotas\_usage](/ja/reference/system-tables/quotas_usage) テーブルのフィールドに対応します。

`ON CLUSTER` 句を使用すると、クラスター上に QUOTA を作成できます。詳細は [Distributed DDL](/ja/reference/statements/distributed-ddl) を参照してください。

**例**

現在のユーザーのクエリ数の上限を、15 か月あたり 123 クエリに制限する例:

```sql theme={null}
ALTER QUOTA IF EXISTS qA FOR INTERVAL 15 month MAX queries = 123 TO CURRENT_USER;
```

デフォルトユーザーについて、30分間の最大実行時間を0.5秒に制限し、5四半期間のクエリ数の上限を321、エラー数の上限を10に設定します。

```sql theme={null}
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;
```
