Which statements are correct for Primary and Unique key constraint?

  1. Primary key constraint creates clustered index by default.

  2. Unique key constraint creates clustered index by default.

  3. Primary key constraint allows null values.

  4. Unique key constraint allows null values


Correct Option: A,D

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Primary key constraint creates clustered index by default - This option is incorrect. While it is true that a primary key constraint creates an index by default, it does not necessarily create a clustered index. By default, a primary key constraint creates a unique nonclustered index. However, you can choose to create a clustered index on the primary key by specifying it explicitly.

Option B) Unique key constraint creates clustered index by default - This option is incorrect. A unique key constraint, like a primary key constraint, does not create a clustered index by default. It creates a unique nonclustered index. You can choose to create a clustered index on a unique key by specifying it explicitly.

Option C) Primary key constraint allows null values - This option is incorrect. A primary key constraint does not allow null values. It enforces the uniqueness of the key and requires that every value in the column(s) defined as the primary key be unique and not null.

Option D) Unique key constraint allows null values - This option is correct. A unique key constraint allows null values. While it enforces the uniqueness of the key, it allows for one null value in the column(s) defined as the unique key. However, it still enforces that all non-null values must be unique.

Based on the explanations above, the correct answer is A and D.

Find more quizzes: