1. You can create an index in the CREATETABLE statement, or use CREATEINDEX or ALTERTABLE to add an index to the table. The following command statement shows how to create a primary key INDEX (PRIMARYKEY), a Union INDEX (UNIQUE), and a general INDEX (INDEX. MysqlALTERTABLE 'table _ name' AD
1. You can CREATE an INDEX in the create table statement, or use create index or alter table to add an INDEX to the TABLE. The following command statements demonstrate how to create a primary key index, a unique index, and an INDEX. Mysql> alter table 'table _ name' AD
1. Create an index
You can CREATE an INDEX in the create table statement, or use the create index or alter table statement to add an INDEX to the TABLE. The following command statements demonstrate how to create a primary key index, a unique index, and an INDEX.
Mysql> alter table 'table _ name' add index | UNIQUE | primary key | 'index _ name' (column list );
Mysql> CREATE [UNIQUE] index'index _ name' ON 'table _ name' (column_list );
2. Re-Indexing
Rebuilding indexes is often used in routine database maintenance operations. After the database has been running for a long time, the indexes may be damaged, and reconstruction is required. Re-indexing data can improve the retrieval efficiency.
Mysql> repair table 'table _ name' QUICK;
3. query data table Indexes
Mysql> show index from | IN 'table _ name ';
4. delete an index
You can use the alter table or drop index statement to delete an INDEX. Drop index can be processed as a statement in alter table. The format is as follows:
Mysql> DROP index 'index _ name' ON 'table _ name' (column list );
Mysql> alter table 'table _ name' drop index | UNIQUE | primary key 'index _ name' (column list );
Original article address: MySQL creates an index, re-creates an index, queries an index, and deletes an index. Thanks to the original author for sharing this article.