system.tables
包含服务器所知的每个表的元数据信息。
Detached 表不会显示在 system.tables 中。
Temporary tables 仅在创建它们的会话中可见于 system.tables。它们的 database 字段为空,且 is_temporary 标志被开启。
列:
-
database(String) — 表所在数据库的名称。 -
name(String) — 表名称。 -
uuid(UUID) — 表的 UUID(原子数据库)。 -
engine(String) — 表引擎名称(不含参数)。 -
is_temporary(UInt8) - 指示表是否为临时表的标志。 -
metadata_path(String) - 文件系统中表元数据的路径。 -
metadata_modification_time(DateTime) - 表元数据的最新修改时间。 -
metadata_version(Int32) - ReplicatedMergeTree 表的元数据版本,非 ReplicatedMergeTree 表为 0。 -
dependencies_table(Array(String)) - 表依赖项(当前表的 materialized views)。 -
create_table_query(String) - 用于创建表的查询。 -
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(不包括任何底层存储)。- 如果表的数据存储在磁盘上,返回在磁盘上使用的空间(即压缩后的)。
- 如果表的数据存储在内存中,返回在内存中使用的字节数的近似值。
-
total_bytes_uncompressed(Nullable(UInt64)) - 总未压缩字节数,如果可以快速确定表在存储中的部分校验和所对应的确切字节数,则返回该值,否则返回NULL(不考虑任何底层存储(如果存在))。 -
lifetime_rows(Nullable(UInt64)) - 自服务器启动以来插入的总行数(仅针对Buffer表)。 -
lifetime_bytes(Nullable(UInt64)) - 自服务器启动以来插入的总字节数(仅针对Buffer表)。 -
comment(String) - 表的注释。 -
has_own_data(UInt8) — 指示表自身是否在磁盘上存储数据或仅访问其他来源的标志。 -
loading_dependencies_database(Array(String)) - 数据库加载依赖项(在当前对象之前应加载的对象列表)。 -
loading_dependencies_table(Array(String)) - 表加载依赖项(在当前对象之前应加载的对象列表)。
system.tables 表用于 SHOW TABLES 查询的实现。
示例