Bird
0
0

Why does a UNIQUE index allow multiple NULL values but still enforce uniqueness on non-NULL values?

hard📝 Conceptual Q10 of 15
SQL - Indexes and Query Performance
Why does a UNIQUE index allow multiple NULL values but still enforce uniqueness on non-NULL values?
ABecause UNIQUE indexes ignore NULL values completely
BBecause NULL is treated as zero internally
CBecause NULL means unknown, so NULLs are not considered equal
DBecause NULL values are automatically converted to unique strings
Step-by-Step Solution
Solution:
  1. Step 1: Understand the meaning of NULL in SQL

    NULL represents unknown or missing data, so two NULLs are not equal to each other.
  2. Step 2: Explain UNIQUE index behavior with NULLs

    Since NULLs are not equal, UNIQUE index allows multiple NULLs but enforces uniqueness on actual known values.
  3. Final Answer:

    Because NULL means unknown, so NULLs are not considered equal -> Option C
  4. Quick Check:

    NULLs are unknown, so multiple allowed in UNIQUE [OK]
Quick Trick: NULL means unknown, so multiple NULLs allowed [OK]
Common Mistakes:
  • Thinking NULL equals zero or empty string
  • Assuming UNIQUE ignores NULLs entirely
  • Believing NULLs are converted to unique strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes