For which of these constraints, an unique index is automatically created while creating constraints?
-
Primary Key
-
Check
-
Unique
-
Not Null
-
Foreign Key
When you create a Primary Key constraint, the database automatically creates a unique index to enforce the uniqueness requirement. Similarly, a Unique constraint also creates a unique index to ensure no duplicate values. Check constraints only validate data integrity rules, Not Null enforces presence of values, and Foreign Key creates relationships but not unique indexes.
Both PRIMARY KEY and UNIQUE constraints guarantee that no two rows can share the same value in the constrained column(s), and the database enforces that guarantee efficiently by automatically building a unique index behind the scenes. CHECK, NOT NULL, and FOREIGN KEY constraints enforce different kinds of rules (value validation, non-nullability, and referential integrity) and don't require a backing unique index.