`

mysql索引

阅读更多
mysql索引
mysql索引相当于目录,使得不用一页一页遍历查找,可以高效获取数据。
1.唯一索引(unique index)强调唯一,即索引值必须唯一。主键就是唯一索引的一种。
创建索引:create unique index 索引名 on 表名(列名)
或alter table tablename add unique index 索引名(列名)
删除索引:drop index 索引名 on 表明
或alter table tablename drop index 索引名
2.全文索引:InnoDB不支持,MyISAM支持。一般在char,varchar,text列上创建
3.单列索引和多列索引(复合索引):最左前缀优化方法unique index(column1,column2)
4.聚簇索引:该索引中键值的逻辑顺序决定了表中相应行的物理顺序。MyISAM没有,InnoDB有(主键就是聚簇索引)。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics