Difficulty: Easy
Correct Answer: ALTER TABLE employees ADD (hire_date DATE);
Explanation:
Introduction / Context:
This question addresses a basic but very important DDL operation in Oracle SQL: adding a new column to an existing table. Database developers and administrators regularly need to change table structures as applications evolve. Knowing the correct syntax for ALTER TABLE is essential for schema maintenance.
Given Data / Assumptions:
Concept / Approach:
In Oracle SQL, the ALTER TABLE statement is used to change the structure of an existing table. To add a new column, the basic pattern is ALTER TABLE table_name ADD (column_name data_type). This operation modifies the table definition in the data dictionary and defines the new column for all existing and future rows. Other keywords such as UPDATE TABLE or CREATE COLUMN are not valid Oracle DDL syntax.
Step-by-Step Solution:
Step 1: Recall the correct generic syntax: ALTER TABLE table_name ADD (column_name data_type).
Step 2: Compare this pattern with option A: ALTER TABLE employees ADD (hire_date DATE); which matches exactly.
Step 3: Examine option B, which uses UPDATE TABLE and ADD COLUMN, which is not valid Oracle syntax because UPDATE is a DML command for data, not structure.
Step 4: Option C uses MODIFY TABLE and ADD COLUMN, but Oracle uses ALTER TABLE, not MODIFY TABLE as a separate keyword.
Step 5: Option D uses CREATE COLUMN, which is not a valid statement in Oracle SQL; CREATE is used for tables, views, and other objects, not for adding columns to existing tables.
Verification / Alternative check:
You can verify by running option A in an Oracle test database with an employees table. The statement will succeed and a new column will appear in the table definition when you describe the table. Attempts to run the statements in options B, C, or D will result in syntax errors, confirming that they are not valid Oracle DDL.
Why Other Options Are Wrong:
Option B mixes UPDATE, a DML statement, with ADD COLUMN, leading to invalid syntax. Option C invents MODIFY TABLE, which is not part of Oracle SQL; Oracle uses ALTER TABLE with various clauses like MODIFY to change existing columns, but not in this form. Option D tries to use CREATE COLUMN, which does not exist as a standalone statement in Oracle.
Common Pitfalls:
Beginners often confuse DDL and DML syntax or try to use keywords from other database systems, such as ADD COLUMN or MODIFY TABLE in non standard combinations. Another pitfall is forgetting to specify data type and constraints when adding a column. Proper use of ALTER TABLE helps maintain schema integrity while evolving the database design.
Final Answer:
The correct way to add a new column is ALTER TABLE employees ADD (hire_date DATE); which is shown in option A.
Discussion & Comments