只对表中的某些值建立目录

只对表中的某些值建立索引
建表

create table z
(id number primary key,
processed_flag varchar2(1),
payload varchar2(20)
)

processed_flag 只有两种值 'Y' or 'N'

只需要对该列的'N'值建索引

create index t_idx on z( decode(processed_flag, 'N', 'N'))

因为decode语法 DECODE(value, if1, then1, if2,then2, if3,then3, . . . else )

当值为'N'时返回'N',非'N'时返回NULL,某人的B*树索引不为NULL值做键