Renaming a table with standard SQL According to the SQL-92 family of standards and common vendor practice, which command is used to change a table’s name (with the appropriate sub-clause)?
-
ARENAME TABLE
-
BCHANGE TABLE
-
CALTER TABLE
-
DNone of the above is correct.
-
EMOVE TABLE
Answer
Correct Answer: ALTER TABLE
Explanation
Introduction / Context:Renaming a table is a DDL operation. While specific syntax varies slightly, standards-aligned and widely supported approaches use the ALTER TABLE command with a RENAME clause (for example, ALTER TABLE old_name RENAME TO new_name).
Given Data / Assumptions:
- We intend to change the identifier of an existing table.
- We are targeting portable, standards-style SQL.
- Privileges, dependencies, and locks are handled appropriately.
Concept / Approach:
The generic approach is ALTER TABLE with a RENAME sub-clause. Different vendors support variants (e.g., Oracle: RENAME old TO new or ALTER TABLE ... RENAME TO; PostgreSQL: ALTER TABLE ... RENAME TO ...; MySQL: RENAME TABLE ... also exists). The safest standards-oriented answer is ALTER TABLE as the top-level verb for renaming.
Step-by-Step Solution:
Use: ALTER TABLE old_name RENAME TO new_name; (or the vendor-equivalent).Ensure dependent objects (views, triggers) adapt automatically or are updated.Consider a synonym/alias to preserve compatibility if needed.Perform the change in maintenance windows to minimize impact.Verification / Alternative check:
Vendor documentation confirms ALTER TABLE as the canonical DDL verb for renaming with RENAME TO sub-clause in standards-compliant engines.
Why Other Options Are Wrong:
- A: RENAME TABLE exists in some DBMSs, but it is not the generic standards-aligned answer.
- B/E: Not standard SQL verbs for renaming.
- D: Incorrect because ALTER TABLE supports renaming.
Common Pitfalls:
- Overlooking dependencies such as foreign keys and code that references the old name.
- Renaming in production without checking replication and tooling impacts.
Final Answer:
ALTER TABLE