oracle索引与like条件的关系
表:gzl_action_define 字段:id:主键,有索引 name:一般字段,无索引 以下是各种写法的结果 1 select t.name from gzl_action_define t where t.id ='12' 使用索引(UNIQUE SCAN) 2 select t.name from gzl_action_define t where t.id like '12%' 使用索引(RANGE SCAN) 3 select t.name from gzl_action_define t where t.id like '%12' 不使用索引(TABLE ACCESS (FULL)) 4 select t.id from gzl_action_define t where t.id like '%12' 使用索引(FAST FULL SCAN) 5 select t.name from gzl_action_define t where t.id like '%12%' 不使用索引(TABLE ACCESS (FULL)) 6 select t.id from gzl_action_define t where t.id like '%12%' 使用索引(FAST FULL SCAN) 3、5的原因不是很清楚,估计是%在前带来的问题
不是写了吗 http://fourfire.iteye.com/blog/219496
怎么知道它执行的时候有没有使用索引阿