Reputation: 14731
How to add a conditional unique constraint on table prod_name
and prod_type
columns of products
table.
I would like to create constraint only when prod_type = 'LOCAL'
How could I do this?
Upvotes: 1
Views: 68
Reputation: 2496
If I understood right, you want this:
create unique index products_name_ui
on products (case when prod_type = 'LOCAL' then prod_name else null end);
Upvotes: 3