Create Unqiue case-insensitive constraint on two varchar fields

Stephen Swensen picture Stephen Swensen · Oct 15, 2010 · Viewed 10.9k times · Source

In Oracle 10g, how do I add a unique case-insensitive constraint on two varchar fields? For example, given the following records already in the table:

"Stephen", "Swensen"
"John", "Smith"

The following inserts would be invalid:

"stephen", "Swensen"
"John", "smith"
"stephen", "swensen"

But the following inserts would be valid:

"Stephen", "Smith"
"John", "Swensen"

Answer

priomsrb picture priomsrb · Apr 4, 2013

I've managed to get it working by doing:

CREATE UNIQUE INDEX person_name_upper ON person(
    UPPER(first_name), UPPER(last_name));