2017-04-04 111 views
-1

创建下面的函数索引时,我正在错过右括号错误。Oracle:创建基于函数的索引

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

基本上我有大量在这个表的用户,我总是被查询的用户,其就业状况不被终止。我需要保留表中的终止雇员,但希望使用此索引提高查询性能。

回答

2

其实我想通了

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

这样指数仅存储的活跃用户。