Syntax

CREATE INDEX index_name ON table_name(column_name1 [, column_name2, …])

CREATE UNIQUE INDEX index_name ON table_name(column_name1 [, column_name2, …]

DROP INDEX index_name ON tbl_name [algorithm_option | lock_option] …

algorithm_option: ALGORITHM [=] {DEFAULT|INPLACE|COPY}

lock_option: LOCK [=] {DEFAULT|NONE|SHARED|EXCLUSIVE}

Remarks

Concepts

An index in a MySQL table works like an index in a book.

Let’s say you have a book about databases and you want to find some information about, say, storage. Without an index (assuming no other aid, such as a table of contents) you’d have to go through the pages one by one, until you found the topic (that’s a “full table scan”). On the other hand, an index has a list of keywords, so you’d consult the index and see that storage is mentioned on pages 113-120, 231, and 354. Then you could flip to those pages directly, without searching (that’s a search with an index, somewhat faster).

Of course, the usefulness of the index depends on many things - a few examples, using the simile above: