Mysql-索引

添加索引

alter table 表名 add index/unique/fulltext [索引名] (字段名);

删除索引

alter table 表名 drop index 索引名;

查看表的所有索引

show index from 表名;

注意:索引在提供查找速度的同时,降低增删改的速度
普通索引 key(字段名1,字段名2,......)
唯一索引 unique key(字段名1,字段名2,......)
主键索引 primary key(字段名1,字段名2,......)
全文索引 fulltext(字段名1,字段名2,......)
组合索引 index(字段名1,字段名2,......)
外键约束 foreign key(字段) references 表名(字段名) innoDB支持

猜你喜欢

转载自blog.51cto.com/13480443/2107332