Home > Database > Mysql Tutorial > body text

How to create mysql index?

藏色散人
Release: 2020-09-15 14:13:02
Original
33164 people have browsed it

The establishment of MySQL index is very important for the efficient operation of MySQL. The index can greatly improve the retrieval speed of MySQL.

How to create mysql index?

How to create a mysql index?

1. Add PRIMARY KEY (primary key index)

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

2. Add UNIQUE (unique index)

mysql>ALTER TABLE `table_name` ADD UNIQUE ( 
`column` 
)
Copy after login

3. Add INDEX (normal index)

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

4. Add FULLTEXT (full text index)

mysql>ALTER TABLE `table_name` ADD FULLTEXT ( `column`)
Copy after login

5. Add multi-column index

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

Related learning recommendations: mysql tutorial(video)

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!