> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-trino-dialect.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-table)的列，仅会在创建它们的那些 `session` 中显示在 `system.columns` 里。它们的 `database` 字段为空。

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

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

**别名：**

* `column` — `name` 的别名。

<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:      ᴺᵁᴸᴸ
```
