# KILL MUTATION (/docs/reference/sql/statements/kill-mutation)



KILL MUTATION [#kill-mutation]

This page describes statements accepted by the Query API in RawTree Cloud
and RawTree BYOC. Its restrictions apply to the API, not to all RawTree SQL.
See [ClickHouse compatibility and API scope](/docs/reference/clickhouse-compatibility).

Syntax [#syntax]

```sql
KILL MUTATION WHERE table = '<table>'
KILL MUTATION WHERE table = '<table>' AND mutation_id = '<mutation_id>'
```

The database filter comes from the request's selected database. Conditions can
appear in either order.

Clauses [#clauses]

| Clause        | Meaning                              |
| ------------- | ------------------------------------ |
| `table`       | Required table name.                 |
| `mutation_id` | Optional ID from `system.mutations`. |

<a id="rawtree-behavior" />

Query API behavior [#query-api-behavior]

* **Supported:** A table condition with an optional mutation ID.
* **Not exposed by the Query API:** Database names in the statement, other conditions, and backslash escapes.
* **Query API scope:** The selected database is added to the mutation filter.

Errors [#errors]

Error: `Unsupported KILL statement.`

Hint:

```text
Only KILL MUTATION WHERE table = '<table>' [AND mutation_id = '<mutation_id>'] is supported. The selected database is applied automatically; find mutation ids in system.mutations.
```

For a target with a backslash, the API returns this error.

```text
Backslash escapes are not supported in KILL MUTATION targets.
```

Hint:

```text
Use literal characters and double single quotes to escape a quote.
```

Examples [#examples]

Add a projection.

```sql test
ALTER TABLE events ADD PROJECTION by_tenant (SELECT `__raw_data.tenant`, count() GROUP BY `__raw_data.tenant`)
```

Materialize it for existing parts.

```sql test
ALTER TABLE events MATERIALIZE PROJECTION by_tenant
```

Inspect mutations before you choose a target.

```sql test
SELECT mutation_id, command, is_done, is_killed FROM system.mutations WHERE database = currentDatabase() AND table = 'events'
```

Stop unfinished mutations for the table.

```sql test
KILL MUTATION WHERE table = 'events'
```

Related [#related]

* [Mutation concepts](/docs/concepts/mutations)
* [Manage mutations](/docs/guides/operate/mutations)
