mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 02:41:59 +00:00
899f93356f
* DOCSUP-2192: Split alter section to separete files. * DOCSUP-2192: Test. * DOCSUP-2192: Fixed cross links. * DOCSUP-2192: Fix links. * DOCSUP-2192: Fix links. * DOCSUP-2192: Fix links. * DOCSUP-2192: Added alter delete and alter update topics. * DOCSUP-2192: Fix one layout mistake and update links. * DOCSUP-2192: Added delete and update sections. Updated alter index.md * DOCSUP-2192: Fix links. Co-authored-by: romanzhukov <romanzhukov@yandex-team.ru>
18 lines
945 B
Markdown
18 lines
945 B
Markdown
---
|
|
toc_priority: 41
|
|
toc_title: ORDER BY
|
|
---
|
|
|
|
# Manipulating Key Expressions {#manipulations-with-key-expressions}
|
|
|
|
``` sql
|
|
ALTER TABLE [db].name [ON CLUSTER cluster] MODIFY ORDER BY new_expression
|
|
```
|
|
|
|
The command changes the [sorting key](../../../engines/table-engines/mergetree-family/mergetree.md) of the table to `new_expression` (an expression or a tuple of expressions). Primary key remains the same.
|
|
|
|
The command is lightweight in a sense that it only changes metadata. To keep the property that data part rows are ordered by the sorting key expression you cannot add expressions containing existing columns to the sorting key (only columns added by the `ADD COLUMN` command in the same `ALTER` query).
|
|
|
|
!!! note "Note"
|
|
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).
|