一:索引类别:
普通索引:index 主键索引:primary
唯一索引:unique :身份证id
全文索引:fultext 最好使用在大文本中
空间索引:spatial:尽量不用
二:创建索引语句:
1.create table student(
id int
email varchar
index(email)
)
2.create index scms_appl_index2 on scms_appl(appl_id,inst_cd)
3.alter table scms_appl add unique index scms_appl_index (inst_cd(11));
三:命中索引 和覆盖索引
即scms_appl有索引scms_appl_index1(appl_id,ln_type_cd)
select * from scms_appl ;此sql命中索引
select t.appl_id,ln_type_cd from scms_appl:此sql覆盖了索引
四:联合索引和索引合并
scms_appl有索引scms_appl_index1(appl_id),scms_appl_index2(appl_brch_cd,inst_cd),scms_appl_index1(appl_id,appl_brch_cd,inst_cd)
select appl_id,appl_brch_cd,inst_cd where scms_appl where appl_id ='474260701' and appl_brch_cd ='500232';:
联合索引:当经常使用到这几个条件时使用
索引合并:单个条件好一点
五:最左前缀匹配原则
从左置右依次匹配原则 当碰到》 like between 停止