CREATE INDEX

statementsupportedTables, views, streams, sequences

docs.snowflake.com ↗

Object: INDEX

Creates a new secondary index in an existing hybrid table and populates the index with data. The creation of an index is an online (non-blocking) operation. The hybrid table remains available for SELECT and DML statements while the index is being built. However, if the hybrid table isn’t in active use and downtime isn’t an issue, Snowflake recommends that you recreate the hybrid table with the indexes defined. See also Create hybrid tables and Index hybrid tables. Generally available to accounts in AWS, Microsoft Azure, and Google Cloud commercial regions. For more information, see Clouds and regions.

Syntax

supportedpartialnot supportednot scored

CREATE [ OR REPLACE ] INDEX [ IF NOT EXISTS ] <index_name>
  ON <table_name>
    ( <col_name> [ , <col_name> , ... ] )
    [ INCLUDE ( <col_name> [ , <col_name> , ... ] ) ]

Parameters

NameRequiredDescription
index_nameSpecifies the identifier for the new index. You must specify a unique name for each new index on a given hybrid table. No other secondary index with either the same name or the same ordered set of columns can exist on the hybrid table.
table_nameSpecifies the name of an existing hybrid table that will hold the new index.
col_nameSpecifies the name of an existing column in the hybrid table. All the requirements for index columns defined at table creation apply to column identifiers. A hybrid table cannot contain two secondary indexes defined on the same ordered set of columns. Columns with geospatial data types (GEOGRAPHY and GEOMETRY), semi-structured data types (ARRAY, OBJECT, VARIANT), and vector data types (VECTOR) are not supported in secondary indexes.
INCLUDE ( col_name [ , col_name , ... ] )optionalSpecifies one or more included columns for a secondary index. Using included columns with a secondary index is particularly useful when queries frequently contain a set of columns in the SELECT list but not in the list of WHERE predicates. For more information, see INCLUDE columns. INCLUDE columns can’t be semi-structured columns (VARIANT, OBJECT, ARRAY) or geospatial columns (GEOGRAPHY, GEOMETRY).

Usage notes

Access control requirements

To create an index, you must use a role that has OWNERSHIP privilege on the hybrid table.

See also

Referenced by