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

> 包含字典相关信息的系统表

# system.dictionaries

<Info>
  **在 ClickHouse Cloud 中查询**

  此系统表中的数据分别保存在 ClickHouse Cloud 各节点的本地。因此，如需查看所有数据的完整情况，需要使用 `clusterAllReplicas` 函数。更多详情请参见[此处](/zh/reference/system-tables/overview#system-tables-in-clickhouse-cloud)。
</Info>

<div id="description">
  ## 描述
</div>

包含[字典](/zh/reference/statements/create/dictionary)的相关信息。

<div id="columns">
  ## 列
</div>

* `database` ([String](/zh/reference/data-types)) — 包含由 DDL query 创建的字典的数据库名称。对于其他字典，该值为空字符串。
* `name` ([String](/zh/reference/data-types)) — 字典名称。
* `uuid` ([UUID](/zh/reference/data-types)) — 字典 UUID。
* `status` ([Enum8('NOT\_LOADED' = 0, 'LOADED' = 1, 'FAILED' = 2, 'LOADING' = 3, 'FAILED\_AND\_RELOADING' = 4, 'LOADED\_AND\_RELOADING' = 5, 'NOT\_EXIST' = 6)](/zh/reference/data-types)) — 字典状态。可能的值：
  * **NOT\_LOADED** — 字典未加载，因为尚未被使用
  * **LOADED** — 字典已成功加载
  * **FAILED** — 由于发生错误，无法加载字典
  * **LOADING** — 字典当前正在加载
  * **LOADED\_AND\_RELOADING** — 字典已成功加载
  * **and is being reloaded right now (frequent reasons: SYSTEM RELOAD DICTIONARY query** — **并且当前正在重新加载 (常见原因：SYSTEM RELOAD DICTIONARY query**
  * **timeout** — **超时**
  * **dictionary config has changed)** — **字典配置已更改) **
  * **FAILED\_AND\_RELOADING** — 由于发生错误，字典未能加载，且当前正在重新加载。
* `origin` ([String](/zh/reference/data-types)) — 描述该字典的 configuration file 路径。
* `type` ([String](/zh/reference/data-types)) — 字典分配类型。在内存中存储字典。
* `key.names` ([Array(String)](/zh/reference/data-types)) — 字典提供的键名数组。
* `key.types` ([Array(String)](/zh/reference/data-types)) — 字典提供的对应键类型数组。
* `attribute.names` ([Array(String)](/zh/reference/data-types)) — 字典提供的属性名数组。
* `attribute.types` ([Array(String)](/zh/reference/data-types)) — 字典提供的对应属性类型数组。
* `bytes_allocated` ([UInt64](/zh/reference/data-types)) — 为字典分配的 RAM 量。
* `hierarchical_index_bytes_allocated` ([UInt64](/zh/reference/data-types)) — 为层级索引分配的 RAM 量。
* `query_count` ([UInt64](/zh/reference/data-types)) — 自字典加载以来或自上次成功重启以来的查询次数。
* `hit_rate` ([Float64](/zh/reference/data-types)) — 对于 cache 字典，值命中缓存的使用占比。
* `found_rate` ([Float64](/zh/reference/data-types)) — 找到值的使用占比。
* `element_count` ([UInt64](/zh/reference/data-types)) — 字典中存储的条目数。
* `load_factor` ([Float64](/zh/reference/data-types)) — 字典的填充率 (对于哈希字典，则为哈希表的填充率) 。
* `source` ([String](/zh/reference/data-types)) — 描述字典数据源的文本。
* `lifetime_min` ([UInt64](/zh/reference/data-types)) — 字典在内存中的最短生命周期，超过该时间后 ClickHouse 会尝试重新加载字典 (如果设置了 invalidate\_query，则仅在其发生变化时才会重新加载) 。以秒为单位设置。
* `lifetime_max` ([UInt64](/zh/reference/data-types)) — 字典在内存中的最长生命周期，超过该时间后 ClickHouse 会尝试重新加载字典 (如果设置了 invalidate\_query，则仅在其发生变化时才会重新加载) 。以秒为单位设置。
* `loading_start_time` ([DateTime](/zh/reference/data-types)) — 开始加载字典的时间。
* `last_successful_update_time` ([DateTime](/zh/reference/data-types)) — 字典上次成功加载或更新完成的时间。有助于监控字典源的问题并排查原因。
* `error_count` ([UInt64](/zh/reference/data-types)) — 自上次成功加载以来的错误次数。有助于监控字典源的问题并排查原因。
* `loading_duration` ([Float32](/zh/reference/data-types)) — 字典加载耗时。
* `last_exception` ([String](/zh/reference/data-types)) — 如果字典无法创建，则为创建或重新加载字典时发生的错误文本。
* `comment` ([String](/zh/reference/data-types)) — 字典的注释文本。

<div id="example">
  ## 示例
</div>

配置字典：

```sql theme={null}
CREATE DICTIONARY dictionary_with_comment
(
    id UInt64,
    value String
)
PRIMARY KEY id
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() TABLE 'source_table'))
LAYOUT(FLAT())
LIFETIME(MIN 0 MAX 1000)
COMMENT 'The temporary dictionary';
```

确保字典已加载。

```sql theme={null}
SELECT * FROM system.dictionaries LIMIT 1 FORMAT Vertical;
```

```text theme={null}
Row 1:
──────
database:                    default
name:                        dictionary_with_comment
uuid:                        4654d460-0d03-433a-8654-d4600d03d33a
status:                      NOT_LOADED
origin:                      4654d460-0d03-433a-8654-d4600d03d33a
type:
key.names:                   ['id']
key.types:                   ['UInt64']
attribute.names:             ['value']
attribute.types:             ['String']
bytes_allocated:             0
query_count:                 0
hit_rate:                    0
found_rate:                  0
element_count:               0
load_factor:                 0
source:
lifetime_min:                0
lifetime_max:                0
loading_start_time:          1970-01-01 00:00:00
last_successful_update_time: 1970-01-01 00:00:00
loading_duration:            0
last_exception:
comment:                     The temporary dictionary
```
