system.tables
Lists tables and views across registered databases and the observing connection's temporary namespace. Use database and schema_name to distinguish objects with the same name.
Columns
| Name | Meaning |
|---|---|
| database | Managed database containing the object. |
| schema_name | Namespace such as main or temp. |
| table_name | Object name. |
| table_type | Object classification, such as BASE TABLE or VIEW. |
| definition | SQL definition text. |
| name | Object-name field for compatible metadata queries. |
| create_table_query | Creation SQL. |
| is_temporary | Whether it is a temporary object. |
| total_rows | Available row estimate, or NULL. |
| total_bytes | Available byte estimate, or NULL. |
The estimates are not a guarantee of an exact count. Use a concrete query when an exact result is required.
Example
sql
CREATE TABLE documented_table(id UInt32);
CREATE VIEW documented_view AS SELECT id FROM documented_table;sql
SELECT table_name, table_type
FROM system.tables
WHERE table_name IN ('documented_table', 'documented_view')
AND schema_name = 'main'
ORDER BY table_name
FORMAT csv;text
"documented_table","BASE TABLE"
"documented_view","VIEW"Management
Validated persistent catalog writes are supported for management. CREATE, ALTER and DROP are the normal object interface; the relation's observational fields are not arbitrary writable table data.
Use the system qualifier through a server interface. See system.columns for fields and SQL statements for object operations.