by Tom.
需求:现有表
create table t
(status varchar2(20) ,
teamid number(2),
job char(10)
)
/
要求status为ACTIVE的时候,teamid和job唯一.
创建唯一索引:
create unique index idx_t_unique on t
(case when status = 'ACTIVE' then teamid else null end,
case when status = 'ACTIVE' then job else null end
)
/
即可以实现该需求.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/6906/viewspace-21991/,如需转载,请注明出处,否则将追究法律责任。