Database index optimization query

Several ways to add indexes
1. Add PRIMARY KEY (primary key index):
ALTER TABLE table_nameADD PRIMARY KEY ( column)
'table_name' table name
column field

Set the column field of the table_name table as the primary key
2. Add UNIQUE (unique index):
ALTER TABLE table_nameADD UNIQUE ( column)
3. Add INDEX (normal index):
Writing one: ALTER TABLE table_nameADD INDEX index_name ( column)
Writing two: CREATE INDEX index_name ON table_name( column1, column2, column3)
4. Add FULLTEXT (full-text indexing):
the ALTER TABLE table_namethe ADD FULLTEXT ( column)
5. The multi-column index is added (combined index):
writing a: the ALTER TABLE table_namethe ADD the iNDEX index_name ( column1, column2, column3)

Written two: the CREATE INDEX index_name ON table_name( column1, column2, column3)
6. lookup table index
SHOW INDEX the FROM table_name;
7. delete the index
DROP INDEX index_name ON table_name;
Finally, attach the index Detailed address: https: //www.cnblogs.com/sheseido/p/ 5825441.html

https://www.cnblogs.com/nickchen121/p/11155947.html

Guess you like

Origin blog.csdn.net/qq_35577329/article/details/106891833