The system table system.tables contains information about all tables, including key attributes such as the table engine, structure (partition/sorting/primary key), storage path, data volume, and more. It is the core system table for viewing table structure and auditing table configuration.
| | | | \
| Field name | Data type | Field description | |
|---|---|---|---|
| \ | |||
| database | String | The name of the database where the table resides. | |
| \ | |||
| name | String | The name of the table. | |
| \ | |||
| engine | String | The table engine name (parameters not included), fixed as "CnchMergeTree". | |
| \ | |||
| is_temporary | UInt8 | Indicates whether the table is temporary: | \ |
| \ | |||
| * 1 = Temporary table (automatically deleted after the session ends); | \ | ||
| * 0 = Permanent table (all examples are 0). | |||
| \ | |||
| data_path | String | The storage path of the table data in the file system. | |
| \ | |||
| metadata_path | String | The storage path of the table metadata in the file system. | |
| \ | |||
| metadata_modification_time | DateTime | The latest modification time of the table metadata. | |
| \ | |||
| dependencies_database | Array(String) | List of databases the table depends on. | |
| \ | |||
| dependencies_table | Array(String) | List of other tables the table depends on, such as materialized views based on the current table, for example 'job_174990_kafka_mv'. | |
| \ | |||
| create_table_query | String | The SQL statement used to create the table. | |
| \ | |||
| engine_full | String | Parameters of the table engine. | |
| \ | |||
| as_select | String | Associated information of the AS SELECT statement when creating the table. | |
| \ | |||
| partition_key | String | The partition key expression specified in the table. | |
| \ | |||
| sorting_key | String | The sorting key expression specified in the table. | |
| \ | |||
| primary_key | String | The primary key expression specified in the table. | |
| \ | |||
| sampling_key | String | The sampling key expression specified in the table. | |
| \ | |||
| storage_policy | String | The name of the storage policy used by the table. | |
| \ | |||
| total_rows | Nullable(UInt64) | Total number of rows in the table. If the exact number of rows in the table cannot be quickly determined, the row count returns as NULL, including underlying buffer tables. | |
| \ | |||
| total_bytes | Nullable(UInt64) | Total number of bytes in the table. If the exact number of bytes stored in the table cannot be quickly determined, the byte count returns as NULL, excluding any underlying storage. | |
| \ | |||
| lifetime_rows | Nullable(UInt64) | NULL | |
| \ | |||
| lifetime_bytes | Nullable(UInt64) | NULL | |
| \ | |||
| comment | String | Comment of the table. | |
| \ | |||
| has_own_data | UInt8 | Indicates whether the table has independent data storage: | \ |
| \ | |||
| * 0 = No independent data; | \ | ||
| * 1 = Has independent data. |
Query tables in the database sales_db, returning only key fields:
SELECT name AS table_name, engine_full, partition_key, primary_key, total_bytes FROM system.tables WHERE database = 'sales_db' LIMIT 10;
Example query results: