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

# detach_tablespaces()

> Detach all tablespaces from a hypertable

export const CHUNK_CAP = 'Chunk';

export const CHUNK = 'chunk';

export const HYPERTABLE_CAP = 'Hypertable';

export const HYPERTABLE = 'hypertable';

<Icon icon="tag" iconType="duotone" /> Since [0.7.0][tsdb-0.7.0]

Detach all tablespaces from a {HYPERTABLE}. After issuing this command
on a {HYPERTABLE}, it no longer has any tablespaces attached to
it. New {CHUNK}s are instead placed in the database's default
tablespace.

## Samples

Detach all tablespaces from the {HYPERTABLE} `conditions`:

```sql theme={"dark"}
SELECT detach_tablespaces('conditions');
```

## Arguments

The syntax is:

```sql theme={"dark"}
SELECT detach_tablespaces(
    hypertable = '<hypertable_name>'
);
```

| Name         | Type     | Default | Required | Description                               |
| ------------ | -------- | ------- | -------- | ----------------------------------------- |
| `hypertable` | REGCLASS | -       | ✔        | Hypertable to detach the tablespace from. |

## Returns

| Name                | Type    | Description                                                               |
| ------------------- | ------- | ------------------------------------------------------------------------- |
| detach\_tablespaces | INTEGER | The total number of tablespaces that were detached from the {HYPERTABLE}. |

[tsdb-0.7.0]: https://github.com/timescale/timescaledb/releases/tag/0.7.0
