system.tables
包含服务器知道的每个表的元数据。 分离的表不在 system.tables
显示。
临时表只在创建它们的会话中的 system.tables
中才可见。它们的数据库字段显示为空,并且 is_temporary
标志显示为开启。
此表包含以下列 (列类型显示在括号中):
-
database
(String) — 表所在的数据库名。 -
name
(String) — 表名。 -
engine
(String) — 表引擎名 (不包含参数)。 -
is_temporary
(UInt8) - 指示表是否是临时的标志。 -
data_path
(String) - 表数据在文件系统中的路径。 -
metadata_path
(String) - 表元数据在文件系统中的路径。 -
metadata_modification_time
(DateTime) - 表元数据的最新修改时间。 -
dependencies_table
(Array(String)) - 表依赖关系 (基于当前表的 物化视图 表) 。 -
create_table_query
(String) - 用于创建表的 SQL 语句。 -
engine_full
(String) - 表引擎的参数。 -
as_select
(String) - 视图的SELECT
语句。 -
partition_key
(String) - 表中指定的分区键表达式。 -
sorting_key
(String) - 表中指定的排序键表达式。 -
primary_key
(String) - 表中指定的主键表达式。 -
sampling_key
(String) - 表中指定的采样键表达式。 -
storage_policy
(String) - 存储策略: -
total_rows
(Nullable(UInt64)) - 总行数,如果无法快速确定表中的确切行数,则行数返回为NULL
(包括底层Buffer
表) 。 -
total_bytes
(Nullable(UInt64)) - 总字节数,如果无法快速确定存储表的确切字节数,则字节数返回为NULL
( 不 包括任何底层存储) 。- 如果表将数据存在磁盘上,返回实际使用的磁盘空间 (压缩后) 。
- 如果表在内存中存储数据,返回在内存中使用的近似字节数。
-
lifetime_rows
(Nullable(UInt64)) - 服务启动后插入的总行数(只针对Buffer
表) 。 -
lifetime_bytes
(Nullable(UInt64)) - 服务启动后插入的总字节数(只针对Buffer
表) 。 -
comment
(String) - 表的注释。 -
has_own_data
(UInt8) — 标志,表示表本身是否在磁盘上存储数据,或者访问其他来源。
system.tables
表被用于 SHOW TABLES
的查询实现中。
示例