A table declares UNIQUE(email). How many rows with email set to NULL can the table hold?
Correct answer
C. Any number, because two NULL values are never considered equal in SQL
20 views
C. Any number, because two NULL values are never considered equal in SQL
20 views
In standard SQL, a UNIQUE constraint is satisfied unless two rows compare equal, and NULL = NULL yields unknown, so multiple NULLs coexist. PostgreSQL, MySQL and SQL Server all follow this rule. Adding NOT NULL is the portable way to require a value, while partial or filtered indexes are often used to allow one NULL per group instead.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.