Reputation: 5040
Can I add a check constraint which makes sure that all values are unique, but allow duplicates of a default value?
Upvotes: 7
Views: 186
Reputation: 132580
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'.
Upvotes: 11