Home > Database > Mysql Tutorial > body text

How to implement addition, deletion, modification and query of mysql index?

青灯夜游
Release: 2020-10-14 16:45:56
Original
3282 people have browsed it

In mysql, you can use the "CREATE INDEX" statement to add an index; use the "SHOW INDEX" statement to view the index; use the "DROP INDEX" statement to delete the index; and modify the index by deleting the original index. Then create an index with the same name as needed to modify the index.

How to implement addition, deletion, modification and query of mysql index?

(Recommended tutorial: mysql video tutorial)

mysql index creation

Creating an index refers to establishing an index on one or more columns of a table, which can improve the access speed to the table. Creating indexes is important for the efficient operation of a MySQL database.

Basic syntax

MySQL provides three methods of creating indexes:

1) Use the CREATE INDEX statement

You can use the CREATE INDEX statement specifically for creating indexes to create an index on an existing table, but this statement cannot create a primary key.

Syntax format:

CREATE <索引名> ON <表名> (<列名> [<长度>] [ ASC | DESC])
Copy after login

The syntax description is as follows: