跳转到主内容
跳转到主内容

system.tables

说明

包含服务器已知的每个表的元数据。

已分离 的表不会在 system.tables 中显示。

临时表 只有在创建它们的会话中才会在 system.tables 中可见。它们会以 database 字段为空且 is_temporary 标志已开启的形式显示。

  • database (String) — 该表所在数据库的名称。
  • name (String) — 表名称。
  • uuid (UUID) — 表的 uuid (Atomic 数据库) 。
  • engine (String) — 表引擎名称 (不带参数) 。
  • is_temporary (UInt8) — 用于指示该表是否为临时表的标志。
  • data_paths (Array(String)) — 表数据在文件系统中的路径。
  • metadata_path (String) — 文件系统中该表元数据的路径。
  • metadata_modification_time (DateTime) — 表元数据的最后修改时间。
  • metadata_version (Int32) — ReplicatedMergeTree 表的元数据版本;对于非 ReplicatedMergeTree 表,该值为 0。
  • dependencies_database (Array(String)) — 数据库依赖项。
  • dependencies_table (Array(String)) — 表依赖项 (当前表的 materialized view) 。
  • create_table_query (String) — 用于创建该表的查询。
  • engine_full (String) — 表引擎参数。
  • as_select (String) — 视图的 SELECT 查询。
  • parameterized_view_parameters (Array(Tuple(name String, type String))) — 参数化视图的参数。
  • partition_key (String) — 表中指定的分区键表达式。
  • sorting_key (String) — 表中指定的排序键表达式。
  • primary_key (String) — 表中指定的主键表达式。
  • sampling_key (String) — 表中指定的采样键表达式。
  • storage_policy (String) — 存储策略。适用于使用 MergeTree 和 Distributed 引擎的表。
  • total_rows (Nullable(UInt64)) — 总行数;如果可以快速确定表中的精确行数,则为该值,否则为 NULL (包括底层 Buffer 表) 。
  • total_bytes (Nullable(UInt64)) — 总字节数;如果能够快速确定该表在存储中的确切字节数,则返回该值,否则为 NULL (不包括任何底层存储) 。如果表将数据存储在磁盘上,则返回磁盘上已使用的空间 (即压缩后的大小) 。如果表将数据存储在内存中,则返回内存中已使用字节数的估算值。
  • total_bytes_uncompressed (Nullable(UInt64)) — 未压缩字节总数;如果可以根据存储中该表的 часть 校验和快速确定精确的字节数,则返回该值,否则返回 NULL (不考虑底层存储 (如果有) ) 。
  • parts (Nullable(UInt64)) — 该表中的 parts 总数。
  • active_parts (Nullable(UInt64)) — 此表中处于活动状态的 parts 数量。
  • total_marks (Nullable(UInt64)) — 该表中所有 parts 的 marks 总数。
  • active_on_fly_data_mutations (UInt64) — 可按需应用的活动数据 mutation (UPDATE 和 DELETE) 总数。
  • active_on_fly_alter_mutations (UInt64) — 可按需应用的活动 alter mutation (MODIFY COLUMN) 总数。
  • active_on_fly_metadata_mutations (UInt64) — 可按需应用的活动元数据 mutation (RENAME) 总数。
  • columns_descriptions_cache_size (UInt64) — *MergeTree 表的列描述缓存大小
  • lifetime_rows (Nullable(UInt64)) — 自服务器启动以来已 INSERT 的总行数 (仅适用于 Buffer 表) 。
  • lifetime_bytes (Nullable(UInt64)) — 自服务器启动以来已 INSERT 的总字节数 (仅适用于 Buffer 表) 。
  • comment (String) — 表注释。
  • has_own_data (UInt8) — 用于指示该表本身是否会在磁盘上存储数据,还是仅访问其他数据源的标志。
  • loading_dependencies_database (Array(String)) — 数据库加载依赖项 (应在当前对象之前加载的对象列表) 。
  • loading_dependencies_table (Array(String)) — 表的加载依赖 (应在当前对象之前加载的对象列表) 。
  • loading_dependent_database (Array(String)) — 加载所依赖的数据库。
  • loading_dependent_table (Array(String)) — 加载依赖表。
  • definer (String) — 该表使用的 SQL 安全定义者名称。

示例

SELECT * FROM system.tables LIMIT 2 FORMAT Vertical;
Row 1:
──────
database:                   base
name:                       t1
uuid:                       81b1c20a-b7c6-4116-a2ce-7583fb6b6736
engine:                     MergeTree
is_temporary:               0
data_paths:                 ['/var/lib/clickhouse/store/81b/81b1c20a-b7c6-4116-a2ce-7583fb6b6736/']
metadata_path:              /var/lib/clickhouse/store/461/461cf698-fd0b-406d-8c01-5d8fd5748a91/t1.sql
metadata_modification_time: 2021-01-25 19:14:32
dependencies_database:      []
dependencies_table:         []
create_table_query:         CREATE TABLE base.t1 (`n` UInt64) ENGINE = MergeTree ORDER BY n
engine_full:                MergeTree ORDER BY n
as_select:                  SELECT database AS table_catalog
partition_key:
sorting_key:                n
primary_key:                n
sampling_key:
storage_policy:             default
total_rows:                 1
total_bytes:                99
lifetime_rows:              ᴺᵁᴸᴸ
lifetime_bytes:             ᴺᵁᴸᴸ
comment:
has_own_data:               0
loading_dependencies_database: []
loading_dependencies_table:    []
loading_dependent_database:    []
loading_dependent_table:       []

Row 2:
──────
database:                   default
name:                       53r93yleapyears
uuid:                       00000000-0000-0000-0000-000000000000
engine:                     MergeTree
is_temporary:               0
data_paths:                 ['/var/lib/clickhouse/data/default/53r93yleapyears/']
metadata_path:              /var/lib/clickhouse/metadata/default/53r93yleapyears.sql
metadata_modification_time: 2020-09-23 09:05:36
dependencies_database:      []
dependencies_table:         []
create_table_query:         CREATE TABLE default.`53r93yleapyears` (`id` Int8, `febdays` Int8) ENGINE = MergeTree ORDER BY id
engine_full:                MergeTree ORDER BY id
as_select:                  SELECT name AS catalog_name
partition_key:
sorting_key:                id
primary_key:                id
sampling_key:
storage_policy:             default
total_rows:                 2
total_bytes:                155
lifetime_rows:              ᴺᵁᴸᴸ
lifetime_bytes:             ᴺᵁᴸᴸ
comment:
has_own_data:               0
loading_dependencies_database: []
loading_dependencies_table:    []
loading_dependent_database:    []
loading_dependent_table:       []