Skip to main content
Version: Candidate-4.0

CREATE INDEX

Creates indexes.

You can create the following indexes:

For detailed instructions and examples on creating these indexes, see the corresponding tutorials listed above.

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 | NGRAMBF | GIN | VECTOR } ]
[(index_property)]
[COMMENT '<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 index. If a column already has an index, you cannot create one more index on it.
USINGNoThe type of the index to create. Valid values:
  • BITMAP (Default)
  • NGRAMBF
  • GIN
  • VECTOR
index_propertyNoThe properties of the index to create. For NGRAMBF, GIN, and VECTOR, you must specify the corresponding properties. For detailed instructions, see the corresponding tutorials.
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 a bitmap index index on the item_id column of sales_records。

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

Relevant SQLs​