是否可以在两列上创建条件索引?
CREATE UNIQUE INDEX idx_dup_wfc
ON WF_WORKFLOW_CLASS (CASE WHEN is_active = 1
THEN (NAME, DEPT_OWNER)
ELSE NULL
END)
返回ORA-00906: missing left parenthesis
,但以下工作
CREATE UNIQUE INDEX idx_dup_wfc
ON WF_WORKFLOW_CLASS (CASE WHEN is_active = 1
THEN NAME
ELSE NULL
END)
答案 0 :(得分:6)
是的,但您必须按列执行CASE:
CREATE UNIQUE INDEX idx_dup_wfc
ON WF_WORKFLOW_CLASS
(CASE WHEN is_active = 1 THEN NAME END
,CASE WHEN is_active = 1 THEN DEPT_OWNER END
)
(代码中的ELSE是多余的)。