创建以下函数索引时,我错过了右括号错误。
create index user_emp_status on users(emp_status <> 'Terminated');
基本上我在这个表中有大量用户,我总是会查询那些未终止雇佣状态的用户。我需要在表中保留已终止的员工,但希望使用此索引来提高查询性能。
答案 0 :(得分:2)
其实我想出来了
create index user_emp_status on users(case emp_status when 'Active' then 'Active' end);
这种方式索引只存储活跃用户。