hariprasadraja
10/10/2019 - 10:50 AM

sql-create index

Saved from https://www.techonthenet.com/mysql/indexes.php

UNIQUE Optional. The UNIQUE modifier indicates that the combination of values in the indexed columns must be unique.

FULLTEXT Optional. The FULLTEXT modifier indexes the entire column and does not allow prefixing. InnoDB and MyISAM tables support this option.

SPATIAL Optional. The SPATIAL modifier indexes the entire column and does not allow indexed columns to contain NULL values. InnoDB (starting in MySQL 5.7) and MyISAM tables support this option.

index_name The name to assign to the index.

table_name The name of the table in which to create the index.

index_col1, index_col2, ... index_col_n The columns to use in the index.

length Optional. If specified, only a prefix of the column is indexed not the entire column. For non-binary string columns, this value is the given number of characters of the column to index. For binary string columns, this value is the given number of bytes of the column to index.

ASC Optional. The index is sorted in ascending order for that column.

DESC Optional. The index is sorted in descending order for that column.

CREATE [UNIQUE | FULLTEXT | SPATIAL] INDEX index_name
  [ USING BTREE | HASH ]
  ON table_name
    (index_col1 [(length)] [ASC | DESC], 
     index_col2 [(length)] [ASC | DESC],
     ...
     index_col_n [(length)] [ASC | DESC]);