CREATE INDEX
You are viewing an old version of this article. View
the current version here.
Syntax
CREATE [ONLINE|OFFLINE] [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name [index_type] ON tbl_name (index_col_name,...) [index_option] ... index_col_name: col_name [(length)] [ASC | DESC] index_type: USING {BTREE | HASH | RTREE} index_option: KEY_BLOCK_SIZE [=] value | index_type | WITH PARSER parser_name | COMMENT 'string'
Description
CREATE INDEX is mapped to an ALTER TABLE statement to create indexes. See ALTER TABLE. CREATE INDEX cannot be used to create a PRIMARY KEY; use ALTER TABLE instead.
Another shortcut, DROP INDEX, allows to remove an index.
As of MariaDB 5.5, a comment of up to 1024 characters is permitted with the COMMENT 'string'
index option.
Index type
See Storage Engine Index Types for details on permitted index_types for each storage engine.
Examples
Creating a unique index:
CREATE UNIQUE INDEX HomePhone ON Employees(Home_Phone);
Comments
Comments loading...
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.