My work
A primary key is unique and only one contains for a table.
There are many unique keys that can contain in a table.
In SQL Server, the primary key is not Nullable. But, a unique key may contain only one null value.
My question:
Practically in SQL Server, the primary key is not nullable. But when it comes in theoretical, why don't we can have exactly only one Null value in the primary key when it allows a Null value in the unique key?
Thanks for answering my question
Sorry for asking a general question, after reading the answer I got a clear idea about null values in DB.
Also, I confused with programming languages like in C++, Jave, where the null value can be comparable. After doing some work, I understand that Null is not comparable in SQL.
In programming languages like in C++, Jave...
Null==Null
returns TRUE
But, in SQL
Null==Null
returns FALSE, because Null value is unknown and it could be any value.
NULL = NULL
(orNULL = anything
, actually) returnsNULL
instead ofFALSE
. A nuance, but it's important more often than you'd think.