Oracle 9i,table表:A+B字段有复合索引,
使用SQL:
select * from table where a='a' and b='b';可以用到该索引使用SQL:
select * from table where (a='a' or a=' ') and b='b';,即带有OR条件的,用到该索引与上面SQL在执行计划上没什么不同?谢谢!

解决方案 »

  1.   

    说的不准确,如果是select * from table where (a='a' or a=' ') and b='b';则可能不用索引,因为有空值。如果是select * from table where (a='a' or a='*') and b='b';,应该可以用到索引了?
      

  2.   

    你这话问的,首先,复合索引有个前置性原则。其次,有没有用到,直接在plsql中按f5
    直接就可以看到是否用到。