MySQL Index

An index is a performance-tuning method of allowing select ,insert order by and group by all the statements re-execute faster retrieval of records. An index creates an entry for each value that appears in the index columns.

Also, User cannot see the index, they are just allow to speed up queries and will be use by database search engine to locate records very fast.

Create an Index:

The syntax for creating a index is:

CREATE [UNIQUE] INDEX index_name
ON table_name (column1, column2, . column_n);

UNIQUE indicates that the combination of values in the index columns must be unique.

Drop an Index :

You can drop an index in MySQL using the DROP INDEX statement.

Syntax :

Below are the syntax of drop index from table in MySQL is :

DROP INDEX index_name ON table_name;
    • index_name :The name of the index to drop.
    • table_name : The name of the table where the index was created.

Rename an Index:

Following are the syntax to rename an index using the ALTER TABLE statement in MySQL is:

ALTER TABLE table_name
  RENAME INDEX index_name TO new_index_name;
  • table_name : The name of the table where the index was created.
  • index_name : The name of the index that you wish to rename.
  • new_index_name : The new name for the index.