There are many types of MySQL indexes, which are basically divided into four categories. The following describes the MySQL indexes for your reference. I hope you can have a deeper understanding of MySQL indexes.
MySQL indexes include:
(1) Common Index
This is the most basic index with no restrictions. It can be created in the following ways:
◆ Create an index
Create index indexName ON mytable (username (length ));
For CHAR and VARCHAR types, the length can be smaller than the actual length of the field; For BLOB and TEXT types, the length must be specified, the same below.
◆ Modify Table Structure
ALTER mytable add index [indexName] ON (username (length ))
◆ When creating a table, specify
Create table mytable (id int not null, username VARCHAR (16) not null, INDEX [indexName] (username (length )));
Syntax for deleting an index:
Drop index [indexName] ON mytable;
(2) unique index
It is similar to the previous normal index. The difference is that the value of the index column must be unique, but a null value is allowed. If it is a composite index, the combination of column values must be unique. It can be created in the following ways:
◆ Create an index
Create unique index indexName ON mytable (username (length ))
◆ Modify Table Structure
ALTER mytable add unique [indexName] ON (username (length ))
◆ When creating a table, specify
Create table mytable (id int not null, username VARCHAR (16) not null, UNIQUE [indexName] (username (length )));
(3) Primary Key Index
It is a special unique index and does not allow null values. Generally, when creating a table, you can create a primary key index at the same time:
Create table mytable (id int not null, username VARCHAR (16) not null, primary key (ID ));
Of course, you can also use the ALTER command. Remember: A table can only have one primary key.
(4) Composite Index
Implement ADO connection to MYSQL
How to Create a MySQL Stored Procedure
How to use mysql triggers
Three examples of mysql triggers
Mysql Aggregate functions