一、索引
1.索引主要分:主键索引、唯一索引、普通索引、全文索引
2.创建索引的目的:加快表的查找和排序
3.创建索引方法:
(1).create index 索引名 on 表名(列表名)
(2).alter table 表名 add index 索引名(列表名)
(3).create table 表名(index 索引名(列表名))
4.查看索引:show index from 表名
5.删除索引:alter table 表名 drop index 索引名
6.组合索引:即多列索引,列表名之间用逗号隔开
7.主键索引:alter table 表名 add primary key(列表名)
8.索引的缺点:占用物理空间,需要动态维护
9.索引创建原则:经常需要搜索的列、经常需要排序的列、作为主键的列、外键等
10.不宜创建索引的对方:数据值较少的列、不常查询排序的列、定义为text, image和bit数据类型的列