DROP COLUMN removes one or more columns from an existing MariaDB table.
Use DROP COLUMN when a field is obsolete, storing redundant data, or replaced by another column. Removing it keeps schemas lean and queries fast.
The command is issued with ALTER TABLE, followed by one or more DROP COLUMN clauses.Options let you control locking and algorithm behavior.
ALTER TABLE Products DROP COLUMN stock;
This permanently deletes the stock column and its data.
ALTER TABLE Customers
DROP COLUMN email,
DROP COLUMN created_at;
Batch execution runs faster than two separate statements.
ALTER TABLE Orders
DROP COLUMN total_amount,
ALGORITHM=INPLACE,
LOCK=NONE;
INPLACE keeps the table writable; LOCK=NONE prevents read/write blocks.
DROP COLUMN fails if foreign keys, indexes, or generated columns rely on it.Remove those dependencies first or use CASCADE.
• Take backups before schema changes.
• Drop in off-peak hours or with minimal locking options.
• Verify application code no longer references the column.
You cannot UNDROP a column.Simulate a rollback with backup/restore or by creating a new column and migrating data instead of dropping.
-- Remove no longer used discount field
ALTER TABLE OrderItems
DROP COLUMN discount,
ALGORITHM=INPLACE,
LOCK=NONE;
The table stays online while the obsolete discount column disappears.
.
Space is reclaimed after OPTIMIZE TABLE or when MariaDB performs internal cleanup during future writes.
Yes, but ensure no other column or index depends on it. Use the same ALTER TABLE ... DROP COLUMN syntax.
CASCADE automatically removes dependent foreign keys and indexes. Review each dependency beforehand to avoid unexpected loss of constraints.