Difficulty: Easy
Correct Answer: ALTER TABLE TableName ADD COLUMN ColumnName
Explanation:
Introduction / Context:
Schema evolution often requires adding new columns. Using the correct Data Definition Language (DDL) syntax avoids errors and ensures portability across relational databases, especially those that follow SQL standards closely.
Given Data / Assumptions:
Concept / Approach:
The standard command to change a table definition is ALTER TABLE. To add a column, use ADD COLUMN followed by the column name (and typically a data type and optional constraints). Some engines permit ADD without the word COLUMN, but ADD COLUMN is widely supported and self-documenting.
Step-by-Step Solution:
Verification / Alternative check:
Execute the statement in a development environment and describe the table to confirm the new column appears with the correct definition.
Why Other Options Are Wrong:
Common Pitfalls:
Adding a NOT NULL column without a DEFAULT to a large table can fail or lock for long periods. Plan migrations with defaults and backfill strategies.
Final Answer:
ALTER TABLE TableName ADD COLUMN ColumnName
Discussion & Comments