> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> Documentation for Manipulating SAMPLE BY expression

# Manipulating Sampling-Key Expressions

The following operations are available:

<h2 id="modify">
  MODIFY
</h2>

```sql theme={null}
ALTER TABLE [db].name [ON CLUSTER cluster] MODIFY SAMPLE BY new_expression
```

The command changes the [sampling key](/docs/reference/engines/table-engines/mergetree-family/mergetree) of the table to `new_expression` (an expression or a tuple of expressions). The primary key must contain the new sample key.

<h2 id="remove">
  REMOVE
</h2>

```sql theme={null}
ALTER TABLE [db].name [ON CLUSTER cluster] REMOVE SAMPLE BY
```

The command removes the [sampling key](/docs/reference/engines/table-engines/mergetree-family/mergetree) of the table.

The commands `MODIFY` and `REMOVE` are lightweight in the sense that they only change metadata or remove files.

<Note>
  It only works for tables in the [MergeTree](/docs/reference/engines/table-engines/mergetree-family/mergetree) family (including [replicated](/docs/reference/engines/table-engines/mergetree-family/replication) tables).
</Note>
