Home > Database > Mysql Tutorial > mysql tutorial: types of mysql indexes

mysql tutorial: types of mysql indexes

黄舟
Release: 2016-12-16 15:53:44
Original
1347 people have browsed it

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 (m.sbmmt.com)!



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template