Description
Contains information about each detached table.
Columns
database(String) — The name of the database the table is in.table(String) — Table name.uuid(UUID) — Table uuid (Atomic database).metadata_path(String) — Path to the table metadata in the file system.is_permanently(UInt8) — Table was detached permanently.
Notes
For DatabaseMySQL and DatabasePostgreSQL, these databases do not own the underlying data — it lives on the remote MySQL/PostgreSQL server. As a result, DROP TABLE on a table from one of these database engines is implemented as detachTablePermanently internally: it only removes ClickHouse’s local tracking of the table, and the table shows up in system.detached_tables with is_permanently = 1, same as an explicit DETACH TABLE PERMANENTLY. The remote data itself is untouched. For persistent MySQL/PostgreSQL databases, the detached state persists across server restarts and reconnections: DatabaseMySQL stores a .remove_flag marker in the metadata directory, while DatabasePostgreSQL stores a .removed marker. Both are reloaded by loadStoredObjects on startup. The table only reappears if a fresh external-database mapping is created without the old metadata directory — for example, if the metadata is removed or the database is created with a different name.
Example
SELECT * FROM system.detached_tables FORMAT Vertical;Row 1:
──────
database: base
table: t1
uuid: 81b1c20a-b7c6-4116-a2ce-7583fb6b6736
metadata_path: /var/lib/clickhouse/store/461/461cf698-fd0b-406d-8c01-5d8fd5748a91/t1.sql
is_permanently: 1