Multiple choice technology databases

Which constraint can be defined only at the column level?

  1. UNIQUE

  2. NOT NULL

  3. CHECK

  4. PRIMARY KEY

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

NOT NULL is the only constraint that must be defined at the column level. All other constraints (UNIQUE, PRIMARY KEY, CHECK, FOREIGN KEY) can be defined at either the column level or table level. NOT NULL cannot be defined at the table level because it applies to individual columns.

AI explanation

To answer this question, you need to understand the different constraints that can be defined in a database. Let's go through each option to understand why it is correct or incorrect:

Option A) UNIQUE - This constraint can be defined at both the column level and the table level. It ensures that the values in a column are unique across all rows in the table.

Option B) NOT NULL - This constraint can only be defined at the column level. It ensures that the column cannot contain any null values.

Option C) CHECK - This constraint can be defined at both the column level and the table level. It allows you to specify a condition that must be met for the values in the column or table.

Option D) PRIMARY KEY - This constraint can be defined at both the column level and the table level. It ensures that the values in the column or combination of columns are unique and not null. It also automatically creates a unique index on the column or combination of columns.

The correct answer is B) NOT NULL. This constraint can only be defined at the column level, ensuring that the column cannot contain any null values.