CS FundamentalsModerateGATE CS · Product placement

Which statement about a UNIQUE constraint versus a PRIMARY KEY in standard SQL is correct?

  1. A. A table may have several UNIQUE constraints, and UNIQUE columns may hold NULLs; there is only one PRIMARY KEY and it cannot be NULL
  2. B. A table may have several PRIMARY KEYs but only one UNIQUE constraint
  3. C. UNIQUE columns cannot be NULL
  4. D. A foreign key can reference only a PRIMARY KEY, never a UNIQUE column

Correct answer: A. A table may have several UNIQUE constraints, and UNIQUE columns may hold NULLs; there is only one PRIMARY KEY and it cannot be NULL

PRIMARY KEY = UNIQUE + NOT NULL, one per table. Any number of UNIQUE constraints are allowed, and NULLs in them are not treated as duplicates in the standard.

More DBMS and SQL questions

Exams that ask this topic