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

> 包含所有表中各列信息的系统表

# system.columns

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

包含所有表中各列的信息。

你可以使用此表获取与 [DESCRIBE TABLE](/zh/reference/statements/describe-table) 查询类似的信息，但可以一次查看多个表。

来自[临时表](/zh/reference/statements/create/table#temporary-tables)的列，仅会在创建它们的那些 `session` 中显示在 `system.columns` 里。它们的 `database` 字段为空。

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

* `database` ([String](/zh/reference/data-types)) — 数据库名称。
* `table` ([String](/zh/reference/data-types)) — 表名称。
* `name` ([String](/zh/reference/data-types)) — 列名称。
* `type` ([String](/zh/reference/data-types)) — 列类型。
* `position` ([UInt64](/zh/reference/data-types)) — 列在表中的序号，从 1 开始。
* `default_kind` ([String](/zh/reference/data-types)) — 默认值的表达式类型 (DEFAULT、MATERIALIZED、ALIAS) ；如果未定义，则为空字符串。
* `default_expression` ([String](/zh/reference/data-types)) — 默认值表达式；如果未定义，则为空字符串。
* `data_compressed_bytes` ([UInt64](/zh/reference/data-types)) — 压缩后数据的大小，以字节为单位。
* `data_uncompressed_bytes` ([UInt64](/zh/reference/data-types)) — 解压后数据的大小，以字节为单位。
* `marks_bytes` ([UInt64](/zh/reference/data-types)) — 标记的大小，以字节为单位。
* `comment` ([String](/zh/reference/data-types)) — 列的注释；如果未定义，则为空字符串。
* `is_in_partition_key` ([UInt8](/zh/reference/data-types)) — 指示该列是否位于分区表达式中的标志。
* `is_in_sorting_key` ([UInt8](/zh/reference/data-types)) — 指示该列是否位于排序键表达式中的标志。
* `is_in_primary_key` ([UInt8](/zh/reference/data-types)) — 指示该列是否位于主键表达式中的标志。
* `is_in_sampling_key` ([UInt8](/zh/reference/data-types)) — 指示该列是否位于采样键表达式中的标志。
* `compression_codec` ([String](/zh/reference/data-types)) — 压缩编解码器名称。
* `character_octet_length` ([Nullable(UInt64)](/zh/reference/data-types)) — 二进制数据、字符数据、文本数据或图像的最大字节长度。在 ClickHouse 中，这只对 FixedString 数据类型有意义。否则返回 NULL 值。
* `numeric_precision` ([Nullable(UInt64)](/zh/reference/data-types)) — 近似数值、精确数值、整数或货币数据的精度。在 ClickHouse 中，对整数类型表示位宽，对 Decimal 类型表示十进制精度。否则返回 NULL 值。
* `numeric_precision_radix` ([Nullable(UInt64)](/zh/reference/data-types)) — 近似数值、精确数值、整数或货币数据精度所使用的数制基数。在 ClickHouse 中，整数类型为 2，Decimal 类型为 10。否则返回 NULL 值。
* `numeric_scale` ([Nullable(UInt64)](/zh/reference/data-types)) — 近似数值、精确数值、整数或货币数据的标度。在 ClickHouse 中，这只对 Decimal 类型有意义。否则返回 NULL 值。
* `datetime_precision` ([Nullable(UInt64)](/zh/reference/data-types)) — DateTime64 数据类型的小数精度。对于其他数据类型，返回 NULL 值。
* `serialization_hint` ([Nullable(String)](/zh/reference/data-types)) — 列的提示信息，用于在插入时根据统计信息选择序列化方式。
* `statistics` ([String](/zh/reference/data-types)) — 为该列创建的统计信息类型。

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

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

```text theme={null}
Row 1:
──────
database:                INFORMATION_SCHEMA
table:                   COLUMNS
name:                    table_catalog
type:                    String
position:                1
default_kind:
default_expression:
data_compressed_bytes:   0
data_uncompressed_bytes: 0
marks_bytes:             0
comment:
is_in_partition_key:     0
is_in_sorting_key:       0
is_in_primary_key:       0
is_in_sampling_key:      0
compression_codec:
character_octet_length:  ᴺᵁᴸᴸ
numeric_precision:       ᴺᵁᴸᴸ
numeric_precision_radix: ᴺᵁᴸᴸ
numeric_scale:           ᴺᵁᴸᴸ
datetime_precision:      ᴺᵁᴸᴸ

Row 2:
──────
database:                INFORMATION_SCHEMA
table:                   COLUMNS
name:                    table_schema
type:                    String
position:                2
default_kind:
default_expression:
data_compressed_bytes:   0
data_uncompressed_bytes: 0
marks_bytes:             0
comment:
is_in_partition_key:     0
is_in_sorting_key:       0
is_in_primary_key:       0
is_in_sampling_key:      0
compression_codec:
character_octet_length:  ᴺᵁᴸᴸ
numeric_precision:       ᴺᵁᴸᴸ
numeric_precision_radix: ᴺᵁᴸᴸ
numeric_scale:           ᴺᵁᴸᴸ
datetime_precision:      ᴺᵁᴸᴸ
```
