# DETACH LEAF

The `DETACH` command detaches a leaf.

Similar to [REMOVE LEAF](https://docs.singlestore.com/db/v9.1/reference/sql-reference/cluster-management-commands/remove-leaf.md) except that it keeps the leaf in the detached state instead of removing it entirely.

## Syntax

```sql
DETACH LEAF 'host':port [KILL] [ENSURE_PARTITION_SAFETY]

```

## Remarks

* `DETACH LEAF` transitions the leaf from the `online` state to the `detached` state.
* `DETACH LEAF` is useful if you would like to temporarily take down a leaf for repairs without erasing it from metadata.
* If MemSQL Ops is not enabled for manual cluster control, then a `REMOVE LEAF` can result in the leaf being added back without user intervention.
* `ENSURE_PARTITION_SAFETY` prevents a leaf (or leaves) from being detached if it contains the last online instance of a partition.
* Use [ATTACH LEAF](https://docs.singlestore.com/db/v9.1/reference/sql-reference/cluster-management-commands/attach-leaf.md) to attach a leaf that is currently in a `detached` state.
* This command causes implicit commits. Refer to [COMMIT](https://docs.singlestore.com/db/v9.1/reference/sql-reference/data-manipulation-language-dml/commit.md) for more information.
* [Node Requirements for SingleStore Commands](https://docs.singlestore.com/db/v9.1/reference/sql-reference/cluster-management-commands.md)
* See the [Permission Matrix](https://docs.singlestore.com/db/v9.1/reference/sql-reference/security-management-commands/permissions-matrix.md) for the required permission.

## Example

```sql
DETACH LEAF '192.168.1.110':3306;

```

## DETACH LEAVES

Detaches all leaves.

Similar to `REMOVE LEAVES`, except it detaches all leaves instead of removing them.

## Syntax

```sql
DETACH LEAVES ('host_1':port_1, ..., 'host_n':port_n) [ENSURE_PARTITION_SAFETY]
```

## Remarks

* `DETACH LEAVES` transitions the leaves from an `online` state to a `detached` state.
* Use [ATTACH LEAF ALL](https://docs.singlestore.com/db/v9.1/reference/sql-reference/cluster-management-commands/attach-leaf-all.md) to attach leaves that are in a `detached` state.
* All leaves must be in the same availability group to `DETACH LEAVES`.
* `DETACH LEAVES` is an all-or-nothing command: either all the leaves will be detached, or none of them will.
* `ENSURE_PARTITION_SAFETY` prevents a leaf (or leaves) from being detached if it contains the last online instance of a partition.

## Example

```sql
DETACH LEAVES ('192.168.1.110':8080, '192.168.1.111':8080, '192.168.1.112':8080);
```

## Related Topics

* [REMOVE LEAF](https://docs.singlestore.com/db/v9.1/reference/sql-reference/cluster-management-commands/remove-leaf.md)
* [ATTACH LEAF](https://docs.singlestore.com/db/v9.1/reference/sql-reference/cluster-management-commands/attach-leaf.md)
* [ATTACH LEAF ALL](https://docs.singlestore.com/db/v9.1/reference/sql-reference/cluster-management-commands/attach-leaf-all.md)

***

Modified at: June 11, 2026

Source: [/db/v9.1/reference/sql-reference/cluster-management-commands/detach-leaf/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/cluster-management-commands/detach-leaf/)

(An index of the documentation is available at /llms.txt)
