ClickHouse/docs/en/sql-reference/statements/alter/index/index.md

23 lines
1.2 KiB
Markdown
Raw Normal View History

---
toc_hidden_folder: true
2022-04-03 23:05:35 +00:00
toc_priority: 42
toc_title: INDEX
---
# Manipulating Data Skipping Indices {#manipulations-with-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.
2021-09-09 07:45:06 +00:00
- `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](../../../../sql-reference/statements/alter/index.md#mutations). To rebuild index over the whole data in the table you need to remove `IN PARTITION` from query.
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.
2022-04-03 23:05:35 +00:00
!!! note "Note"
Index manipulation is supported only for tables with [`*MergeTree`](../../../../engines/table-engines/mergetree-family/mergetree.md) engine (including [replicated](../../../../engines/table-engines/mergetree-family/replication.md) variants).