Home  >  Article  >  Database  >  How to create an index in mysql

How to create an index in mysql

little bottle
little bottleOriginal
2019-05-29 16:45:5111071browse

Index is a very important thing in MySQL. Now I will take you to learn how to create an index in MySQL.

How to create an index in mysql

It is divided into five indexing methods:

1. Add PRIMARY KEY (primary key index)

mysql>ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` )

2. Add UNIQUE (unique index)

mysql>ALTER TABLE `table_name` ADD UNIQUE (
`column`
)

3. Add INDEX (normal index)

mysql>ALTER TABLE `table_name` ADD INDEX index_name ( `column` )

4. Add FULLTEXT (full text index)

mysql>ALTER TABLE `table_name` ADD FULLTEXT ( `column`)

5. Add multi-column index

mysql>ALTER TABLE `table_name` ADD INDEX index_name ( `column1`, `column2`, `column3` )

The above is the detailed content of How to create an index in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn