> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-sync-clickhouse-operator-docs-7e82242.mintlify.site/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](/core/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](/core/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.

<Info>
  ***

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