Skip to content

Commit caad43b

Browse files
committed
added system.tables_with_history
1 parent d3aa107 commit caad43b

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: system.tables_with_history
3+
---
4+
5+
Provides metadata information for all tables, including historical tables. It includes details such as table properties, creation time, number of rows, data size, and more.
6+
7+
See also: [SHOW DROP TABLES](../../10-sql-commands/00-ddl/01-table/show-drop-tables.md)
8+
9+
```sql title='Examples:'
10+
SELECT * FROM system.tables_with_history LIMIT 3;
11+
12+
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
13+
│ catalog │ database │ name │ table_id │ total_columns │ engine │ engine_full │ cluster_by │ is_transient │ is_attach │ created_on │ dropped_on │ updated_on │ num_rows │ data_size │ data_compressed_size │ index_size │ number_of_segments │ number_of_blocks │ owner │ comment │ table_type │
14+
├─────────┼──────────┼────────────────────┼─────────────────────┼───────────────┼───────────────────────┼───────────────────────┼────────────┼──────────────┼───────────┼────────────────────────────┼─────────────────────┼────────────────────────────┼──────────────────┼──────────────────┼──────────────────────┼──────────────────┼────────────────────┼──────────────────┼──────────────────┼─────────┼────────────┤
15+
│ default │ system │ metrics │ 46116860184273879195 │ SystemMetrics │ SystemMetrics │ │ │ │ 2024-11-20 21:04:12.950815NULL2024-11-20 21:04:12.950815NULLNULLNULLNULLNULLNULLNULL │ │ BASE TABLE │
16+
│ default │ system │ clustering_history │ 46116860184273879256 │ SystemLogTable │ SystemLogTable │ │ │ │ 2024-11-20 21:04:12.952439NULL2024-11-20 21:04:12.952439NULLNULLNULLNULLNULLNULLNULL │ │ BASE TABLE │
17+
│ default │ system │ queries_profiling │ 46116860184273879417 │ QueriesProfilingTable │ QueriesProfilingTable │ │ │ │ 2024-11-20 21:04:12.952588NULL2024-11-20 21:04:12.952588NULLNULLNULLNULLNULLNULLNULL │ │ BASE TABLE │
18+
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
19+
```
20+
21+
To show the schema of `system.tables_with_history`, use `DESCRIBE system.tables_with_history`:
22+
23+
```sql
24+
DESCRIBE system.tables_with_history
25+
26+
┌─────────────────────────────────────────────────────────────────────────────────────────┐
27+
│ Field │ Type │ Null │ Default │ Extra │
28+
├──────────────────────┼─────────────────┼────────┼──────────────────────────────┼────────┤
29+
│ catalog │ VARCHAR │ NO │ '' │ │
30+
│ database │ VARCHAR │ NO │ '' │ │
31+
│ name │ VARCHAR │ NO │ '' │ │
32+
│ table_id │ BIGINT UNSIGNED │ NO │ 0 │ │
33+
│ total_columns │ BIGINT UNSIGNED │ NO │ 0 │ │
34+
│ engine │ VARCHAR │ NO │ '' │ │
35+
│ engine_full │ VARCHAR │ NO │ '' │ │
36+
│ cluster_by │ VARCHAR │ NO │ '' │ │
37+
│ is_transient │ VARCHAR │ NO │ '' │ │
38+
│ is_attach │ VARCHAR │ NO │ '' │ │
39+
│ created_on │ TIMESTAMP │ NO │ '1970-01-01 00:00:00.000000' │ │
40+
│ dropped_on │ TIMESTAMP │ YES │ NULL │ │
41+
│ updated_on │ TIMESTAMP │ NO │ '1970-01-01 00:00:00.000000' │ │
42+
│ num_rows │ BIGINT UNSIGNED │ YES │ NULL │ │
43+
│ data_size │ BIGINT UNSIGNED │ YES │ NULL │ │
44+
│ data_compressed_size │ BIGINT UNSIGNED │ YES │ NULL │ │
45+
│ index_size │ BIGINT UNSIGNED │ YES │ NULL │ │
46+
│ number_of_segments │ BIGINT UNSIGNED │ YES │ NULL │ │
47+
│ number_of_blocks │ BIGINT UNSIGNED │ YES │ NULL │ │
48+
│ owner │ VARCHAR │ YES │ NULL │ │
49+
│ comment │ VARCHAR │ NO │ '' │ │
50+
│ table_type │ VARCHAR │ NO │ '' │ │
51+
└─────────────────────────────────────────────────────────────────────────────────────────┘
52+
```
53+

docs/en/sql-reference/10-sql-commands/00-ddl/01-table/show-drop-tables.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
88

99
Lists the dropped tables in the current or a specified database.
1010

11+
See also: [system.tables_with_history](../../../00-sql-reference/20-system-tables/system-tables-with-history.md)
12+
1113
## Syntax
1214

1315
```sql

0 commit comments

Comments
 (0)