Rnet
Rnet

Reputation: 5040

Oracle constraint

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

Answers (1)

Tony Andrews
Tony Andrews

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

Related Questions