请问用< 或 > 号会用到索引吗?select * from tabname where phonenum > '12345';

解决方案 »

  1.   

    不能用索引的情况
    1)单行函数nvl,decode.....
    2)>,<,>=,<=
    3) not..in,exists,is null
    4)is null'
    所以<,<不用索引
      

  2.   

    scott 下 dept表
    SQL> select * from dept where deptno >'30';    DEPTNO DNAME          LOC
    ---------- -------------- -------------
            40 OPERATIONS     BOSTON
            50 ACCOUNTING     NEW YORK
    | Id  | Operation                   | Name    | Rows  | Bytes | Cost (%CPU)| Tim
    e     |--------------------------------------------------------------------------------
    -------|   0 | SELECT STATEMENT            |         |     3 |    60 |     2   (0)| 00:
    00:01 ||   1 |  TABLE ACCESS BY INDEX ROWID| DEPT    |     3 |    60 |     2   (0)| 00:
    00:01 ||*  2 |   INDEX RANGE SCAN          | PK_DEPT |     3 |       |     1   (0)| 00:
    00:01 |SQL> select * from dept where deptno <> '30';    DEPTNO DNAME          LOC
    ---------- -------------- -------------
            50 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            40 OPERATIONS     BOSTON--------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |     3 |    60 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| DEPT |     3 |    60 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------
      

  3.   

    当然要用了,在oracle中肯定是用个,在其他的不敢保证。