简体   繁体   中英

Oracle constraint

我是否可以添加检查约束,以确保所有值都是唯一的,但允许重复默认值?

You can achieve this using a funcction-based index (FBI):

create unique index idx on my_table (case when col != 'DEFAULT' then col end));

That creates a unique index on all values except 'DEFAULT'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM