ITPEC FE Morning October 2022 Question 27

Topic: Databases

In the process of table implementation, which of the following is an appropriate SQL statement that removes a column in an existing table?

Explanation

ALTER TABLE … DROP COLUMN — changing a table's structure is a DDL job, and DDL removes objects with DROP.

The structure of an existing table is changed with ALTER TABLE: ADD COLUMN adds a column and DROP COLUMN removes one, as in ALTER TABLE table_name DROP COLUMN column_name. DROP is the DDL verb for removing schema objects (DROP TABLE, DROP INDEX). DELETE and UPDATE are DML: they work on the rows, not the structure.

Answer (b)

Why not others:

  • •(a) — right statement, wrong verb: DELETE removes rows (DELETE FROM), and there is no DELETE COLUMN clause
  • •(c) — wrong on both counts: there is no UPDATE TABLE statement for structure, and no DELETE COLUMN clause
  • •(d) — right clause, wrong statement: UPDATE changes values in existing rows and cannot alter the table's definition

Key rule: DDL (CREATE, ALTER, DROP) changes the structure of objects; DML (INSERT, UPDATE, DELETE) changes the rows. Removing structure uses DROP, removing data uses DELETE.

Databases · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.