> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-trino-dialect.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> System table containing information about each detached table.

# system.detached_tables

<h2 id="description">
  Description
</h2>

Contains information about each detached table.

<h2 id="columns">
  Columns
</h2>

* `database` ([String](/reference/data-types/string)) — The name of the database the table is in.
* `table` ([String](/reference/data-types/string)) — Table name.
* `uuid` ([UUID](/reference/data-types/uuid)) — Table uuid (Atomic database).
* `metadata_path` ([String](/reference/data-types/string)) — Path to the table metadata in the file system.
* `is_permanently` ([UInt8](/reference/data-types/int-uint)) — Table was detached permanently.

<h2 id="notes">
  Notes
</h2>

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.

<h2 id="example">
  Example
</h2>

```sql theme={null}
SELECT * FROM system.detached_tables FORMAT Vertical;
```

```text theme={null}
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
```
