列存储索引分为两种类型:聚集的列存储索引和非聚集的列存储索引,在一个表上只能创建一个聚集索引,要么是聚集的列存储索引,要么是聚集的行存储索引,然而一个表上可以创建多个非聚集索引。
一,创建列存储索引创建列存储索引的语法如下:
-- Create a clustered columnstore index on disk-based table. CREATE CLUSTERED COLUMNSTORE INDEX index_name ON { database_name.schema_name.table_name | schema_name.table_name | table_name } [ WITH ( < with_option> [ ,...n ] ) ] [ ON <on_option> ] [ ; ] --Create a nonclustered columnstore index on a disk-based table. CREATE [NONCLUSTERED] COLUMNSTORE INDEX index_name ON { database_name.schema_name.table_name | schema_name.table_name | table_name } ( column [ ,...n ] ) [ WHERE <filter_expression> [ AND <filter_expression> ] ] [ WITH ( < with_option> [ ,...n ] ) ] [ ON <on_option> ] [ ; ] <with_option> ::= DROP_EXISTING = { ON | OFF } -- default is OFF | MAXDOP = max_degree_of_parallelism | ONLINE = { ON | OFF } | COMPRESSION_DELAY = { 0 | delay [ Minutes ] } | DATA_COMPRESSION = { COLUMNSTORE | COLUMNSTORE_ARCHIVE } [ ON PARTITIONS ( { partition_number_expression | range } [ ,...n ] ) ] <on_option>::= partition_scheme_name ( column_name ) | filegroup_name | "default" <filter_expression> ::= column_name IN ( constant [ ,...n ] | column_name { IS | IS NOT | = | <> | != | > | >= | !> | < | <= | !< } constant