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

> 包含所有已缓存文件 schema 信息的系统表。

# system.schema_inference_cache

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

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

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

包含所有已缓存文件 schema 的相关信息。

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

* `storage` ([String](/zh/reference/data-types/index)) — 存储名称：File、URL、S3 或 HDFS。
* `source` ([String](/zh/reference/data-types/index)) — 文件来源。
* `format` ([String](/zh/reference/data-types/index)) — 格式名称。
* `additional_format_info` ([String](/zh/reference/data-types/index)) — 用于识别 schema 所需的附加信息。例如，格式特定的设置。
* `registration_time` ([DateTime](/zh/reference/data-types/index)) — schema 添加到缓存中的时间戳。
* `schema` ([Nullable(String)](/zh/reference/data-types/index)) — 已缓存的 schema。
* `number_of_rows` ([Nullable(UInt64)](/zh/reference/data-types/index)) — 文件在给定格式下的行数。它用于缓存数据文件的简单 `count()` 结果，以及在推断 schema 期间缓存元数据中的行数。
* `schema_inference_mode` ([Nullable(String)](/zh/reference/data-types/index)) — schema 推断模式。

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

假设我们有一个 `data.jsonl` 文件，内容如下：

```json theme={null}
{"id" :  1, "age" :  25, "name" :  "Josh", "hobbies" :  ["football", "cooking", "music"]}
{"id" :  2, "age" :  19, "name" :  "Alan", "hobbies" :  ["tennis", "art"]}
{"id" :  3, "age" :  32, "name" :  "Lana", "hobbies" :  ["fitness", "reading", "shopping"]}
{"id" :  4, "age" :  47, "name" :  "Brayan", "hobbies" :  ["movies", "skydiving"]}
```

<Tip>
  将 `data.jsonl` 放到 `user_files_path` 目录中。你可以在
  ClickHouse 配置文件中找到该目录。默认值为：

  ```sql theme={null}
  <user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
  ```
</Tip>

打开 `clickhouse-client` 并运行 `DESCRIBE` 查询：

```sql theme={null}
DESCRIBE file('data.jsonl') SETTINGS input_format_try_infer_integers=0;
```

```response theme={null}
┌─name────┬─type────────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐
│ id      │ Nullable(Float64)       │              │                    │         │                  │                │
│ age     │ Nullable(Float64)       │              │                    │         │                  │                │
│ name    │ Nullable(String)        │              │                    │         │                  │                │
│ hobbies │ Array(Nullable(String)) │              │                    │         │                  │                │
└─────────┴─────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘
```

来看看 `system.schema_inference_cache` 表中的内容：

```sql theme={null}
SELECT *
FROM system.schema_inference_cache
FORMAT Vertical
```

```response theme={null}
Row 1:
──────
storage:                File
source:                 /home/droscigno/user_files/data.jsonl
format:                 JSONEachRow
additional_format_info: schema_inference_hints=, max_rows_to_read_for_schema_inference=25000, schema_inference_make_columns_nullable=true, try_infer_integers=false, try_infer_dates=true, try_infer_datetimes=true, try_infer_numbers_from_strings=true, read_bools_as_numbers=true, try_infer_objects=false
registration_time:      2022-12-29 17:49:52
schema:                 id Nullable(Float64), age Nullable(Float64), name Nullable(String), hobbies Array(Nullable(String))
```

<div id="see-also">
  ## 另请参阅
</div>

* [从输入数据自动推断 schema](/zh/concepts/features/interfaces/schema-inference)
