Does unique constraint on multiple columns create index on each column

Viewed 516

If i create a unique constraint like this unique(colA, colB);

Does it create 2 indexes, 1 for each column? Or how does it actually work internally?

1 Answers

It will create only one index on two columns and both the column combinedly can not contain duplicate in the entire table.

You can add multiple duplicates for colA but considering that the colB is different for each row having same colA and vice-versa.

colA   colB
Tejash SO
Tejash SO1
Tejash SO2

Allowed

or

colA colB
SO1  TEJASH
SO2  TEJASH
SO3  TEJASH

is also allowed.

Related