In SQL Data Definition Language (DDL), what can the ALTER TABLE statement be used to do?

Database SQL for Database Construction Difficulty: Easy
Choose an option
  • A
    Change the table structure (add/modify/drop columns, constraints, etc.)
  • B
    Change the table data (update specific rows)
  • C
    Add rows to the table
  • D
    Delete rows from the table
  • E
    Export table data to a file

Answer

Correct Answer: Change the table structure (add/modify/drop columns, constraints, etc.)

Explanation

Introduction / Context:SQL separates data definition (DDL) from data manipulation (DML). ALTER TABLE is a DDL command used to evolve schema safely as requirements change.

Given Data / Assumptions:

  • We want to modify a table's structure or constraints.
  • We are not directly editing row contents via ALTER.
  • Standard SQL semantics apply.

Concept / Approach:ALTER TABLE alters schema objects: add/drop columns, change data types where allowed, add/drop constraints (PRIMARY KEY, UNIQUE, FOREIGN KEY, CHECK), rename objects (vendor-specific), or adjust storage options. DML like UPDATE, INSERT, DELETE manipulates data, not schema.

Step-by-Step Solution:

Identify need: structural change → ALTER TABLE.Data changes use UPDATE/INSERT/DELETE, not ALTER.Therefore, ALTER TABLE is for schema evolution.

Verification / Alternative check:RDBMS documentation classifies ALTER TABLE under DDL, distinct from DML statements.

Why Other Options Are Wrong:Change table data / add rows / delete rows: Performed by UPDATE, INSERT, DELETE respectively. Export data: Handled by utilities (COPY, bcp) or SELECT INTO OUTFILE (vendor-specific), not ALTER.

Common Pitfalls:Altering types or constraints on large tables can lock or rewrite data; plan maintenance windows and backups.

Final Answer:Change the table structure (add/modify/drop columns, constraints, etc.)

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