In SQL schema evolution, which command is used to add a new column or define an integrity constraint on an existing table?

Difficulty: Easy

Correct Answer: ALTER TABLE

Explanation:

Introduction / Context:Real-world databases evolve. You often need to add columns, enforce new constraints, or change properties without recreating the table. SQL provides a command specifically for altering the definition of existing schema objects, including tables, while preserving data where possible.

Given Data / Assumptions:

  • We want to change table structure without dropping and recreating it.
  • Tasks include adding columns and adding constraints (e.g., PRIMARY KEY, UNIQUE, CHECK, FOREIGN KEY).
  • We seek the standard SQL command name.

Concept / Approach:ALTER TABLE is the SQL statement used to modify table metadata: adding/dropping columns, creating/dropping constraints, and in some dialects altering data types or defaults. Pseudo-commands like “ADD COLUMN” may be clauses within ALTER TABLE, but ALTER TABLE is the full, correct command verb across SQL implementations.

Step-by-Step Solution:

Identify the operation: change table definition (columns/constraints). Recall the SQL DDL verbs: CREATE, ALTER, DROP. Map to ALTER TABLE for structural modifications. Select “ALTER TABLE.”

Verification / Alternative check:Vendor documentation consistently uses ALTER TABLE ... ADD COLUMN ... or ... ADD CONSTRAINT ..., confirming the correct command name.

Why Other Options Are Wrong:

  • ADD/INSERT/MODIFY COLUMN alone: Not standalone SQL verbs; typically clauses under ALTER TABLE.
  • None: Incorrect because ALTER TABLE is standard.

Common Pitfalls:Confusing syntax clauses with the top-level command; assuming vendor-specific shorthands are portable.

Final Answer:ALTER TABLE

More Questions from Database Systems

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion