What is the main purpose of the UNIQUE constraint in SQL?
easy📝 Conceptual Q11 of 15
SQL - Table Constraints
What is the main purpose of the UNIQUE constraint in SQL?
ATo automatically generate unique IDs
BTo allow NULL values in a column
CTo speed up query performance
DTo prevent duplicate values in a column or group of columns
Step-by-Step Solution
Solution:
Step 1: Understand the UNIQUE constraint and compare to options
The UNIQUE constraint ensures that all values in a column or a set of columns are different from each other. The other options describe different SQL features, but only "To prevent duplicate values in a column or group of columns" correctly describes the UNIQUE constraint.
Final Answer:
To prevent duplicate values in a column or group of columns -> Option D
Quick Check:
UNIQUE constraint = prevent duplicates [OK]
Quick Trick:UNIQUE means no two rows can have same value [OK]
Common Mistakes:
MISTAKES
Confusing UNIQUE with PRIMARY KEY
Thinking UNIQUE speeds up queries
Assuming UNIQUE allows duplicates
Master "Table Constraints" in SQL
9 interactive learning modes - each teaches the same concept differently