sqlcmd.net validated sql reference
intermediate defining MySQL MariaDB SQL Server PostgreSQL SQLite

Remove A Column From A Table With ALTER TABLE DROP COLUMN

Permanently delete a column and all its data from a table using ALTER TABLE.

Docker-validated Not currently validation-green

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.

Rows loaded before the example query runs.
Setup
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');
Shared across supported engines.
SQL
ALTER TABLE users
DROP COLUMN temp_code;

SELECT
  id,
  name
FROM
  users
ORDER BY
  id;
Returned rows for the shared example.
idname
1Alice
2Bob

The syntax is identical across all supported engines. The temp_code column and its data are removed permanently.

Where this command helps.

  • removing a temporary or migration column after a data backfill is complete
  • cleaning up deprecated fields from a table schema

What the command is doing.

ALTER TABLE ... DROP COLUMN removes a column from a table along with all data stored in that column. MySQL, MariaDB, SQL Server, and PostgreSQL use ALTER TABLE t DROP COLUMN col. SQLite added DROP COLUMN support in version 3.35.0 (released March 2021); earlier versions require recreating the table. The operation is irreversible — always back up data or verify the column is unused before dropping. In SQL Server the COLUMN keyword is optional: ALTER TABLE t DROP col also works.