Blog· Tested on ClickHouse 26.4

Finding the tables someone forgot to attach

system.detached_parts lists detached parts but nothing listed detached tables. A contributor's PR added system.detached_tables in 24.7, and I closed my own issue nine months later.

Source: github.com

DETACH TABLE takes a table out of service without deleting anything, and the table then vanishes from system.tables and from every inventory query built on it. Forget to attach it again on one node and nothing complains until a query fails with UNKNOWN_TABLE. Parts already had system.detached_parts; I asked for the same for tables: a system.detached_tables listing what is missing.

A community member answered the same day by pointing at an existing PR, #65400 by k-morozov, which merged on 2024-07-17 and shipped in 24.7. The issue stayed open because nobody linked the two; I noticed the merge in April 2025 and closed it myself.

The columns differ from my sketch (database, table, uuid, metadata_path, is_permanently). On 26.4 it needs an Atomic database; the default clickhouse local database cannot list detached tables.

CREATE DATABASE d ENGINE = Atomic;
CREATE TABLE d.t (x UInt8) ENGINE = MergeTree ORDER BY x;
CREATE TABLE d.u (x UInt8) ENGINE = MergeTree ORDER BY x;
DETACH TABLE d.t;
DETACH TABLE d.u PERMANENTLY;
SELECT database, table, is_permanently FROM system.detached_tables WHERE database = 'd' ORDER BY table;
d   t   0
d   u   1

A plain detach comes back after a restart; a permanent one does not. See also dropping detached parts and finding orphan tables.

feature-requestsystem-tablesoperations

Discussion

Comments live in GitHub Discussions. Sign in with GitHub to join in.