2022-08-28 13:53:52 +00:00
---
2022-08-28 13:58:27 +00:00
slug: /en/operations/system-tables/tables
2022-08-28 13:53:52 +00:00
---
2022-06-02 10:55:18 +00:00
# tables
2020-06-18 08:24:31 +00:00
2021-07-29 15:20:55 +00:00
Contains metadata of each table that the server knows about.
2020-06-18 08:24:31 +00:00
2021-04-17 23:05:32 +00:00
[Detached ](../../sql-reference/statements/detach.md ) tables are not shown in `system.tables` .
2020-06-18 08:24:31 +00:00
2021-07-29 15:20:55 +00:00
[Temporary tables ](../../sql-reference/statements/create/table.md#temporary-tables ) are visible in the `system.tables` only in those session where they have been created. They are shown with the empty `database` field and with the `is_temporary` flag switched on.
2020-06-18 08:24:31 +00:00
2021-04-17 22:47:43 +00:00
Columns:
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `database` ([String](../../sql-reference/data-types/string.md)) — The name of the database the table is in.
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `name` ([String](../../sql-reference/data-types/string.md)) — Table name.
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — Table uuid (Atomic database).
2022-05-21 15:30:57 +00:00
2023-04-19 15:55:29 +00:00
- `engine` ([String](../../sql-reference/data-types/string.md)) — Table engine name (without parameters).
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `is_temporary` ([UInt8](../../sql-reference/data-types/int-uint.md)) - Flag that indicates whether the table is temporary.
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `data_paths` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - Paths to the table data in the file systems.
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `metadata_path` ([String](../../sql-reference/data-types/string.md)) - Path to the table metadata in the file system.
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `metadata_modification_time` ([DateTime](../../sql-reference/data-types/datetime.md)) - Time of latest modification of the table metadata.
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `dependencies_database` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - Database dependencies.
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `dependencies_table` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - Table dependencies ([MaterializedView](../../engines/table-engines/special/materializedview.md) tables based on the current table).
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `create_table_query` ([String](../../sql-reference/data-types/string.md)) - The query that was used to create the table.
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `engine_full` ([String](../../sql-reference/data-types/string.md)) - Parameters of the table engine.
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `as_select` ([String](../../sql-reference/data-types/string.md)) - `SELECT` query for view.
2021-10-21 19:41:11 +00:00
2023-04-19 15:55:29 +00:00
- `partition_key` ([String](../../sql-reference/data-types/string.md)) - The partition key expression specified in the table.
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `sorting_key` ([String](../../sql-reference/data-types/string.md)) - The sorting key expression specified in the table.
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `primary_key` ([String](../../sql-reference/data-types/string.md)) - The primary key expression specified in the table.
2021-04-17 22:47:43 +00:00
2023-04-19 15:55:29 +00:00
- `sampling_key` ([String](../../sql-reference/data-types/string.md)) - The sampling key expression specified in the table.
2021-04-17 22:47:43 +00:00
2023-04-19 15:55:29 +00:00
- `storage_policy` ([String](../../sql-reference/data-types/string.md)) - The storage policy:
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- [MergeTree ](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes )
- [Distributed ](../../engines/table-engines/special/distributed.md#distributed )
2020-06-18 08:24:31 +00:00
2023-06-02 11:30:05 +00:00
- `total_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - Total number of rows, if it is possible to quickly determine exact number of rows in the table, otherwise `NULL` (including underlying `Buffer` table).
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `total_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - Total number of bytes, if it is possible to quickly determine exact number of bytes for the table on storage, otherwise `NULL` (does not includes any underlying storage).
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- If the table stores data on disk, returns used space on disk (i.e. compressed).
- If the table stores data in memory, returns approximated number of used bytes in memory.
2020-06-18 08:24:31 +00:00
2023-04-19 15:55:29 +00:00
- `lifetime_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - Total number of rows INSERTed since server start (only for `Buffer` tables).
2020-07-11 12:19:06 +00:00
2023-04-19 15:55:29 +00:00
- `lifetime_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - Total number of bytes INSERTed since server start (only for `Buffer` tables).
2020-07-11 12:19:06 +00:00
2023-04-19 15:55:29 +00:00
- `comment` ([String](../../sql-reference/data-types/string.md)) - The comment for the table.
2021-05-29 13:42:21 +00:00
2023-04-19 15:55:29 +00:00
- `has_own_data` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Flag that indicates whether the table itself stores some data on disk or only accesses some other source.
2021-05-29 13:42:21 +00:00
2023-04-19 15:55:29 +00:00
- `loading_dependencies_database` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - Database loading dependencies (list of objects which should be loaded before the current object).
2022-05-21 15:30:57 +00:00
2023-04-19 15:55:29 +00:00
- `loading_dependencies_table` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - Table loading dependencies (list of objects which should be loaded before the current object).
2022-05-21 15:30:57 +00:00
2023-04-19 15:55:29 +00:00
- `loading_dependent_database` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - Dependent loading database.
2022-05-21 15:30:57 +00:00
2023-04-19 15:55:29 +00:00
- `loading_dependent_table` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - Dependent loading table.
2022-05-21 15:30:57 +00:00
2020-06-18 08:24:31 +00:00
The `system.tables` table is used in `SHOW TABLES` query implementation.
2020-08-06 08:50:29 +00:00
2021-04-17 22:47:43 +00:00
**Example**
2020-12-03 19:27:55 +00:00
```sql
2021-04-17 22:47:43 +00:00
SELECT * FROM system.tables LIMIT 2 FORMAT Vertical;
2020-12-03 21:44:17 +00:00
```
2020-12-03 19:27:55 +00:00
```text
Row 1:
──────
2021-05-29 13:42:21 +00:00
database: base
name: t1
uuid: 81b1c20a-b7c6-4116-a2ce-7583fb6b6736
engine: MergeTree
2020-12-03 19:27:55 +00:00
is_temporary: 0
2021-05-29 13:42:21 +00:00
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
2020-12-03 19:27:55 +00:00
dependencies_database: []
dependencies_table: []
2021-05-29 13:42:21 +00:00
create_table_query: CREATE TABLE base.t1 (`n` UInt64) ENGINE = MergeTree ORDER BY n SETTINGS index_granularity = 8192
engine_full: MergeTree ORDER BY n SETTINGS index_granularity = 8192
2021-10-21 19:41:11 +00:00
as_select: SELECT database AS table_catalog
2021-05-29 13:42:21 +00:00
partition_key:
sorting_key: n
primary_key: n
sampling_key:
storage_policy: default
total_rows: 1
total_bytes: 99
lifetime_rows: ᴺᵁᴸᴸ
lifetime_bytes: ᴺᵁᴸᴸ
comment:
2021-10-21 19:41:11 +00:00
has_own_data: 0
2022-05-21 15:30:57 +00:00
loading_dependencies_database: []
loading_dependencies_table: []
loading_dependent_database: []
loading_dependent_table: []
2020-12-03 19:27:55 +00:00
Row 2:
──────
2021-05-29 13:42:21 +00:00
database: default
name: 53r93yleapyears
2020-12-03 19:27:55 +00:00
uuid: 00000000-0000-0000-0000-000000000000
2021-05-29 13:42:21 +00:00
engine: MergeTree
2020-12-03 19:27:55 +00:00
is_temporary: 0
2021-05-29 13:42:21 +00:00
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
2020-12-03 19:27:55 +00:00
dependencies_database: []
dependencies_table: []
2021-05-29 13:42:21 +00:00
create_table_query: CREATE TABLE default.`53r93yleapyears` (`id` Int8, `febdays` Int8) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity = 8192
engine_full: MergeTree ORDER BY id SETTINGS index_granularity = 8192
2021-10-21 19:41:11 +00:00
as_select: SELECT name AS catalog_name
2021-05-29 13:42:21 +00:00
partition_key:
sorting_key: id
primary_key: id
sampling_key:
storage_policy: default
total_rows: 2
total_bytes: 155
lifetime_rows: ᴺᵁᴸᴸ
lifetime_bytes: ᴺᵁᴸᴸ
comment:
2021-10-21 19:41:11 +00:00
has_own_data: 0
2022-05-21 15:30:57 +00:00
loading_dependencies_database: []
loading_dependencies_table: []
loading_dependent_database: []
loading_dependent_table: []
2020-12-03 19:27:55 +00:00
```