ClickHouse/docs/en/sql-reference/statements/alter/index/index.md
Aleksei Semiglazov f47e1ff102
CLICKHOUSE-1194: add skipping index to the beginning of the list
add the FIRST keyword to the ADD INDEX command to be able to add index in the beginning of the list.

Signed-off-by: Aleksei Semiglazov <asemiglazov@cloudflare.com>
2021-07-01 19:37:48 +01:00

1.1 KiB

toc_hidden_folder toc_priority toc_title
true 42 INDEX

Manipulating Data Skipping Indices

The following operations are available:

  • ALTER TABLE [db].name ADD INDEX name expression TYPE type GRANULARITY value [FIRST|AFTER name] - Adds index description to tables metadata.

  • ALTER TABLE [db].name DROP INDEX name - Removes index description from tables metadata and deletes index files from disk.

  • ALTER TABLE [db.]table MATERIALIZE INDEX name IN PARTITION partition_name - The query rebuilds the secondary index name in the partition partition_name. Implemented as a mutation.

The first two commands are lightweight in a sense that they only change metadata or remove files.

Also, they are replicated, syncing indices metadata via ZooKeeper.

!!! note "Note" Index manipulation is supported only for tables with *MergeTree engine (including replicated variants).