|
我觉得这里采用基于函数的索引,应该比较合适,写了个例子,不知道为什么没有成功(没有走索引), 哪位指正一下
create table test
(id varchar2(100),
name varchar2(100)
);
create index test_idx on test(case when id is NULL then 'N' end);
SQL> select /*+index (test test_idx) */ * from test where id is NULL;
no rows selected
Execution Plan
----------------------------------------------------------
Plan hash value: 217508114
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 104 | 2 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| TEST | 1 | 104 | 2 (0)| 00:00:01 |
-------------------------------------------------------------------------- |
|