Rebuild a table to remove a column (portable approach)
SQL
Hard
2 views
Problem Description
Some DBs cannot drop a column easily. Show a safe 3-step approach to remove column temp_flag from Orders.
Output Format
DDL/DML statements
Sample Test Case
Input:
Orders with temp_flag
Output:
Orders without temp_flag
Constraints
Use create-copy-swap pattern
Official Solution
CREATE TABLE Orders_new AS SELECT order_id, customer_id, order_date, status FROM Orders; DROP TABLE Orders; ALTER TABLE Orders_new RENAME TO Orders;
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!