After a table has been created, which SQL command is used to modify its structure (for example, add or drop columns and constraints)?

Difficulty: Easy

Correct Answer: ALTER TABLE [TableName].

Explanation:


Introduction / Context:
SQL distinguishes between changing data and changing structure. Data Manipulation Language (DML) statements edit row contents, while Data Definition Language (DDL) statements create or alter schema objects. This question asks which command changes an existing table's structure.



Given Data / Assumptions:

  • The table already exists.
  • Required changes include adding or dropping columns, indexes, or constraints.
  • We are looking for the standard DDL verb.


Concept / Approach:

ALTER TABLE is the portable DDL statement used across major SQL databases to modify the definition of an existing table. UPDATE modifies data, not structure. MODIFY TABLE and CHANGE TABLE are not standard SQL commands (though some vendors support ALTER TABLE ... MODIFY COLUMN as a clause).



Step-by-Step Solution:

1) Choose ALTER TABLE to change schema elements of an existing table.2) Provide specific subclauses (for example, ADD COLUMN, DROP COLUMN, ADD CONSTRAINT).3) Validate in a non-production environment before applying to production.


Verification / Alternative check:

Consult vendor documentation; ALTER TABLE is universally recognized for structural changes, while UPDATE affects rows and should not be used for DDL.



Why Other Options Are Wrong:

UPDATE TABLE: DML for row values, not structure.

MODIFY TABLE / CHANGE TABLE: not standard SQL verbs; vendors use ALTER TABLE with MODIFY or CHANGE as subclauses, not as the main command.



Common Pitfalls:

Attempting to use non-portable syntax across engines; forgetting to consider locking and online options during ALTER operations on large tables.



Final Answer:

ALTER TABLE [TableName].

More Questions from Managing Databases with Oracle

Discussion & Comments

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