Types of indexes
There are many types of indexes in MySQL. The types and creation methods of indexes are introduced below.
1. Ordinary index
The most basic index in MySQL, no data must meet uniqueness restrictions. There are several ways to create it.索 Create ordinary indexes directly
Create index_name on table_name (Columns_list (length)); Table structure Create a normal index when creating a normal index
alter table_name add index [index_name] on (columns_list (length)) ;
Directly specify when creating a table
create table table_name ([…], index [index_name] (columns_list (length))) ;
2 . Duplicate values cannot appear on the index column where the unique index
is located and must be unique. There are several ways to create it.
Create indexes directly reCreate unique index index_name on table_name (columns_list (length)); mns_list (length); table_name ([…], unique [index_name] (columns_list (length))) ;
3. Primary key index
The primary key is a unique index, but its name must be specified as "PRIMARY KEY". Each table can only have one primary key. The primary key index is created when the table is created. The example is as follows:
create table shili (sid int not null auto_increment,…,primary key (sid) ) ;
4. Full-text index
The index type of full-text index is FULL TEXT. Full-text indexes can be created on VARCHAR or TEXT type columns, and their characteristics are suitable for indexing larger string data.
The above is the mysql tutorial: the types of mysql indexes. For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!