Skip to main content

CREATE INDEX

Description

This statement is used to create indexes. You can use this statement to create only Bitmap indexes. For usage notes and scenarios of Bitmap indexes, see Bitmap index.

tip

This operation requires the ALTER privilege on the target table. You can follow the instructions in GRANT to grant this privilege.

Syntax

CREATE INDEX index_name ON table_name (column_name) [USING BITMAP] [COMMENT'']

Parameter

ParameterRequiredDescription
index_nameYesThe index name. For naming conventions, see System Limits.
table_nameYesThe name of the table.
column_nameYesThe name of the column to build index on. One column can have only one BITMAP index. If a column already has an index, you cannot create one more index on it.
COMMENTNoThe comment for the index.

Examples

Create a table sales_records as follows:

CREATE TABLE sales_records
(
record_id int,
seller_id int,
item_id int
)
DISTRIBUTED BY hash(record_id)
PROPERTIES (
"replication_num" = "3"
);

Create an index index on the item_id column of sales_records

CREATE INDEX index3 ON sales_records (item_id) USING BITMAP COMMENT '';

Relevant SQLs