Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle constraint

Tags:

oracle

Can I add a check constraint which makes sure that all values are unique, but allow duplicates of a default value?

like image 931
Rnet Avatar asked Oct 27 '11 11:10

Rnet


People also ask

What are the three types of constraint?

The three primary constraints that project managers should be familiar with are time, scope, and cost. These are frequently known as the triple constraints or the project management triangle.

How many types of constraints are present in Oracle?

Oracle Database lets you create six types of constraints and lets you declare them in two ways. The six types of integrity constraint are described briefly here and more fully in "Semantics ": A NOT NULL constraint prohibits a database value from being null.


1 Answers

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'.

like image 58
Tony Andrews Avatar answered Nov 04 '22 11:11

Tony Andrews