ClickHouse/docs/en/sql-reference/statements/alter/projection.md
2022-08-29 12:19:50 -04:00

1.6 KiB

slug sidebar_position sidebar_label title
/en/sql-reference/statements/alter/projection 49 PROJECTION Manipulating Projections

The following operations with projections are available:

  • ALTER TABLE [db].name ADD PROJECTION name ( SELECT <COLUMN LIST EXPR> [GROUP BY] [ORDER BY] ) - Adds projection description to tables metadata.

  • ALTER TABLE [db].name DROP PROJECTION name - Removes projection description from tables metadata and deletes projection files from disk. Implemented as a mutation.

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

  • ALTER TABLE [db.]table CLEAR PROJECTION name IN PARTITION partition_name - Deletes projection files from disk without removing description. Implemented as a mutation.

The commands ADD, DROP and CLEAR are lightweight in a sense that they only change metadata or remove files.

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

:::note
Projection manipulation is supported only for tables with *MergeTree engine (including replicated variants). :::