1. Home
  2. Data Science
  3. SQL for Data Analysis
  4. A table declares UNIQUE(email). How many rows with email…

Added 30 Nov -0001

A table declares UNIQUE(email). How many rows with email set to NULL can the table hold?

  1. Two, because the index allows one NULL per page of the stored data
  2. None, because UNIQUE implies NOT NULL for every column that it covers
  3. Any number, because two NULL values are never considered equal in SQL Correct answer
  4. Exactly one, because UNIQUE treats NULL like any other distinct value

Correct answer

C. Any number, because two NULL values are never considered equal in SQL

20 views

MCQSEXAM

Explanation

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.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More SQL for Data Analysis MCQs

Practise all SQL for Data Analysis MCQs

Similar MCQs