|
| 1 | +--- |
| 2 | +title: information_schema.tables |
| 3 | +--- |
| 4 | + |
| 5 | +The `information_schema.tables` system table is a view that provides metadata about all tables across all databases, including their schema, type, engine, and creation details. It also includes storage metrics such as data length, index length, and row count, offering insights into table structure and usage. |
| 6 | + |
| 7 | +See also: [system.tables](system-tables.md) |
| 8 | + |
| 9 | +```sql title='Examples:' |
| 10 | +SELECT * FROM information_schema.tables LIMIT 3; |
| 11 | + |
| 12 | +┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ |
| 13 | +│ table_catalog │ table_schema │ table_name │ table_type │ engine │ create_time │ drop_time │ data_length │ index_length │ table_rows │ auto_increment │ table_collation │ data_free │ table_comment │ |
| 14 | +├────────────────────┼────────────────────┼────────────┼────────────┼────────┼────────────────────────────┼─────────────────────┼──────────────────┼──────────────────┼──────────────────┼────────────────┼─────────────────┼───────────┼───────────────┤ |
| 15 | +│ default │ default │ json_table │ BASE TABLE │ FUSE │ 2024-11-18 23:22:21.576421 │ NULL │ 68 │ 425 │ 1 │ NULL │ NULL │ NULL │ │ |
| 16 | +│ information_schema │ information_schema │ views │ VIEW │ VIEW │ 2024-11-20 21:04:12.952792 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ │ |
| 17 | +│ information_schema │ information_schema │ statistics │ VIEW │ VIEW │ 2024-11-20 21:04:12.952795 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ │ |
| 18 | +└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
| 19 | +``` |
| 20 | + |
| 21 | +To show the schema of `information_schema.tables`, use `DESCRIBE information_schema.tables`: |
| 22 | + |
| 23 | +```sql |
| 24 | +DESCRIBE information_schema.tables; |
| 25 | + |
| 26 | +┌────────────────────────────────────────────────────────────────────────────────────┐ |
| 27 | +│ Field │ Type │ Null │ Default │ Extra │ |
| 28 | +├─────────────────┼─────────────────┼────────┼──────────────────────────────┼────────┤ |
| 29 | +│ table_catalog │ VARCHAR │ NO │ '' │ │ |
| 30 | +│ table_schema │ VARCHAR │ NO │ '' │ │ |
| 31 | +│ table_name │ VARCHAR │ NO │ '' │ │ |
| 32 | +│ table_type │ VARCHAR │ NO │ '' │ │ |
| 33 | +│ engine │ VARCHAR │ NO │ '' │ │ |
| 34 | +│ create_time │ TIMESTAMP │ NO │ '1970-01-01 00:00:00.000000' │ │ |
| 35 | +│ drop_time │ TIMESTAMP │ YES │ NULL │ │ |
| 36 | +│ data_length │ BIGINT UNSIGNED │ YES │ NULL │ │ |
| 37 | +│ index_length │ BIGINT UNSIGNED │ YES │ NULL │ │ |
| 38 | +│ table_rows │ BIGINT UNSIGNED │ YES │ NULL │ │ |
| 39 | +│ auto_increment │ NULL │ NO │ NULL │ │ |
| 40 | +│ table_collation │ NULL │ NO │ NULL │ │ |
| 41 | +│ data_free │ NULL │ NO │ NULL │ │ |
| 42 | +│ table_comment │ VARCHAR │ NO │ '' │ │ |
| 43 | +└────────────────────────────────────────────────────────────────────────────────────┘ |
| 44 | +``` |
0 commit comments