I have been asked several times in interviews this question.
Why an unique key allows one null value?
I searched for the answers but I couldn't find one.
Please help me on this
sql serverunique-constraint
I have been asked several times in interviews this question.
Why an unique key allows one null value?
I searched for the answers but I couldn't find one.
Please help me on this
Best Answer
Apparently, this is not the behaviour as defined in the ANSI SQL standard documents (as Martin Smith's link suggests).
Other database servers behave differently in this respect. E.g. PostgreSQL allows you to do this:
See dbfiddle.
When working with Oracle, you can do this (or something similar), too -
Dbfiddle here.