mysql索引

索引分为聚簇索引和非聚簇索引两种,聚簇索引是按照数据存放的物理位置为顺序的,而非聚簇索引就不一样了;聚簇索引能提高多行检索的速度,而非聚簇索引对于单行的检索很快。

MySQL索引结构

    BTree索引

    Hash索引

    full-text全文索引

    R-Tree索引

MySQL中常见索引有:

一、普通索引(index)

create index 索引名称 on 表名(列名)//创建索引
drop 索引名称 on 表名;//删除索引
show index from 表名;//显示索引
create index index_name on tab1(extra(32));//对于创建索引时如果是BLOB 和 TEXT 类型,必须指定length

二、唯一索引(unique)
create unique index 索引名 on 表名(列名)
drop unique index 索引名 on 表名

三、主键索引
alter table 表名 add primary key(列名);
alter table 表名 drop primary key;
alter table 表名  modify  列名 int, drop primary key;

四、组合索引
create index ix_name_email on in3(name,email);

五全文索引
alter table 表名 add fulltext 表名(列名)


原文地址:https://www.cnblogs.com/shymen/p/8660865.html