Bird
0
0

Which of the following SQL statements correctly adds a NOT NULL constraint to an existing column phone in table contacts?

easy📝 Syntax Q3 of 15
SQL - Table Constraints

Which of the following SQL statements correctly adds a NOT NULL constraint to an existing column phone in table contacts?

AALTER TABLE contacts ADD NOT NULL phone;
BALTER TABLE contacts CHANGE phone NOT NULL;
CALTER TABLE contacts SET phone NOT NULL;
DALTER TABLE contacts MODIFY phone VARCHAR(15) NOT NULL;
Step-by-Step Solution
Solution:
  1. Step 1: Understand how to alter column constraints

    To add NOT NULL, you modify the column definition with the data type and NOT NULL.
  2. Step 2: Check syntax correctness

    ALTER TABLE contacts MODIFY phone VARCHAR(15) NOT NULL; uses correct syntax: ALTER TABLE ... MODIFY column datatype NOT NULL. Others are invalid or incomplete.
  3. Final Answer:

    ALTER TABLE contacts MODIFY phone VARCHAR(15) NOT NULL; -> Option D
  4. Quick Check:

    Use MODIFY with datatype and NOT NULL to alter column [OK]
Quick Trick: Use MODIFY with datatype to add NOT NULL [OK]
Common Mistakes:
MISTAKES
  • Trying to add NOT NULL without datatype
  • Using ADD NOT NULL which is invalid
  • Using SET or CHANGE incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes