ClickHouse/docs/en/sql-reference/statements/alter/sample-by.md

20 lines
761 B
Markdown
Raw Normal View History

2020-08-27 13:10:10 +00:00
---
toc_priority: 41
toc_title: SAMPLE BY
---
# Manipulating Sampling-Key Expressions {#manipulations-with-sampling-key-expressions}
Syntax:
2020-08-27 13:10:10 +00:00
``` sql
ALTER TABLE [db].name [ON CLUSTER cluster] MODIFY SAMPLE BY new_expression
```
The command changes the [sampling key](../../../engines/table-engines/mergetree-family/mergetree.md) of the table to `new_expression` (an expression or a tuple of expressions).
The command is lightweight in the sense that it only changes metadata. The primary key must contain the new sample key.
2020-08-27 13:10:10 +00:00
!!! note "Note"
2021-10-06 06:02:20 +00:00
It only works for tables in the [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md) family (including [replicated](../../../engines/table-engines/mergetree-family/replication.md) tables).