Q.While creating a table, which constraint does not allow insertion of duplicate values in the table ? (A) UNIQUE (B) DISTINCT (C) NOT NULL (D) HAVING
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →A constraint is a rule enforced at the database level; UNIQUE is the constraint that prevents duplicate values in a column. The answer is (A).
When you design a database table, you want to enforce certain rules on what data can be stored. These rules are called constraints, and they live in the table definition itself — the database engine checks them automatically every time you try to insert or update a row.
The question asks which constraint blocks duplicate values. Let's see what each option actually does.
Understanding the options
-
UNIQUE — This is a table constraint. When you declare a column (or combination of columns) as
UNIQUE, the database refuses anyINSERTorUPDATEthat would create a duplicate value in that column. For example:CREATE TABLE students ( roll_no INT UNIQUE, name VARCHAR(50) );Now you cannot have two students with the same
roll_no. The database enforces this rule. -
DISTINCT — This is not a constraint; it's a keyword used in
SELECTqueries to filter out duplicate rows from the result set. It doesn't prevent duplicates from being inserted — it only affects what you see when you retrieve data:SELECT DISTINCT city FROM customers;The table can still contain duplicate cities;
DISTINCTjust shows each city once in the output. -
NOT NULL — This constraint ensures a column cannot contain
NULLvalues. It has nothing to do with duplicates. You can have a column that isNOT NULLand still insert the same value multiple times:CREATE TABLE products ( product_id INT NOT NULL, name VARCHAR(100) ); ``` …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.