Oracle:创建基于函数的索引

时间:2017-04-04 02:53:44

标签: oracle

创建以下函数索引时,我错过了右括号错误。

create index user_emp_status on users(emp_status <> 'Terminated');

基本上我在这个表中有大量用户,我总是会查询那些未终止雇佣状态的用户。我需要在表中保留已终止的员工,但希望使用此索引来提高查询性能。

1 个答案:

答案 0 :(得分:2)

其实我想出来了

create index user_emp_status on users(case emp_status when 'Active' then 'Active' end);

这种方式索引只存储活跃用户。