system.tables

Contains metadata of each table that the server knows about.

Detached tables are not shown in system.tables.

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.

Columns:

  • database (String) — The name of the database the table is in.

  • name (String) — Table name.

  • engine (String) — Table engine name (without parameters).

  • is_temporary (UInt8) - Flag that indicates whether the table is temporary.

  • data_path (String) - Path to the table data in the file system.

  • metadata_path (String) - Path to the table metadata in the file system.

  • metadata_modification_time (DateTime) - Time of latest modification of the table metadata.

  • dependencies_database (Array(String)) - Database dependencies.

  • dependencies_table (Array(String)) - Table dependencies (MaterializedView tables based on the current table).

  • create_table_query (String) - The query that was used to create the table.

  • engine_full (String) - Parameters of the table engine.

  • 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 storage policy:

  • total_rows (Nullable(UInt64)) - Total number of rows, if it is possible to quickly determine exact number of rows in the table, otherwise NULL (including underying Buffer table).

  • total_bytes (Nullable(UInt64)) - 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).

    • 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.
  • lifetime_rows (Nullable(UInt64)) - Total number of rows INSERTed since server start (only for Buffer tables).

  • lifetime_bytes (Nullable(UInt64)) - Total number of bytes INSERTed since server start (only for Buffer tables).

  • comment (String) - The comment for the table.

The system.tables table is used in SHOW TABLES query implementation.

Example

  1. SELECT * FROM system.tables LIMIT 2 FORMAT Vertical;
  1. Row 1:
  2. ──────
  3. database: base
  4. name: t1
  5. uuid: 81b1c20a-b7c6-4116-a2ce-7583fb6b6736
  6. engine: MergeTree
  7. is_temporary: 0
  8. data_paths: ['/var/lib/clickhouse/store/81b/81b1c20a-b7c6-4116-a2ce-7583fb6b6736/']
  9. metadata_path: /var/lib/clickhouse/store/461/461cf698-fd0b-406d-8c01-5d8fd5748a91/t1.sql
  10. metadata_modification_time: 2021-01-25 19:14:32
  11. dependencies_database: []
  12. dependencies_table: []
  13. create_table_query: CREATE TABLE base.t1 (`n` UInt64) ENGINE = MergeTree ORDER BY n SETTINGS index_granularity = 8192
  14. engine_full: MergeTree ORDER BY n SETTINGS index_granularity = 8192
  15. partition_key:
  16. sorting_key: n
  17. primary_key: n
  18. sampling_key:
  19. storage_policy: default
  20. total_rows: 1
  21. total_bytes: 99
  22. lifetime_rows: ᴺᵁᴸᴸ
  23. lifetime_bytes: ᴺᵁᴸᴸ
  24. comment:
  25. Row 2:
  26. ──────
  27. database: default
  28. name: 53r93yleapyears
  29. uuid: 00000000-0000-0000-0000-000000000000
  30. engine: MergeTree
  31. is_temporary: 0
  32. data_paths: ['/var/lib/clickhouse/data/default/53r93yleapyears/']
  33. metadata_path: /var/lib/clickhouse/metadata/default/53r93yleapyears.sql
  34. metadata_modification_time: 2020-09-23 09:05:36
  35. dependencies_database: []
  36. dependencies_table: []
  37. create_table_query: CREATE TABLE default.`53r93yleapyears` (`id` Int8, `febdays` Int8) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity = 8192
  38. engine_full: MergeTree ORDER BY id SETTINGS index_granularity = 8192
  39. partition_key:
  40. sorting_key: id
  41. primary_key: id
  42. sampling_key:
  43. storage_policy: default
  44. total_rows: 2
  45. total_bytes: 155
  46. lifetime_rows: ᴺᵁᴸᴸ
  47. lifetime_bytes: ᴺᵁᴸᴸ
  48. comment: