索引
小于 1 分钟约 159 字
索引时帮助mysql高效获取数据的数据结构。
索引的本质:索引就是数据结构(树结构 => B+树)
主键索引
创建索引
create index 索引名 on 表名(字段)
alter table 表名 add primary key(字段)
唯一索引
创建索引
create unique index 索引名 on 表名(字段)
alter table 表名 add unique(字段)
普通组合索引
创建索引
create index index 索引名 on 表名(字段)
alter table 表名 add index(字段)
唯一组合索引
创建索引
create unique index index 索引名 on 表名(字段)