Example 1
Drop a temporary migration column after a backfill is complete
After dropping temp_code, the SELECT confirms only id and name remain. The migration data (MIG001, MIG002) is gone and cannot be recovered without a backup. If a constraint, index, or computed column references the column being dropped, the engine will raise an error — remove those dependencies first.
CREATE TABLE users (id INT, name VARCHAR(50), temp_code VARCHAR(20));
INSERT INTO
users (id, name, temp_code)
VALUES
(1, 'Alice', 'MIG001'),
(2, 'Bob', 'MIG002');ALTER TABLE users
DROP COLUMN temp_code;
SELECT
id,
name
FROM
users
ORDER BY
id;| id | name |
|---|---|
| 1 | Alice |
| 2 | Bob |
The syntax is identical across all supported engines. The temp_code column and its data are removed permanently.