3207
MariaDBERRORNotableDDLHIGH confidence
Column used by a default generated column cannot be dropped
Production Risk
Low — DDL error.
Why it happens
- 1Attempting to drop a base column that a generated column's expression depends on.
How to reproduce
trigger — this will error
trigger — this will error
ALTER TABLE t1 DROP COLUMN base_col; -- where gen_col AS (base_col * 2)
expected output
ERROR 3207 (HY000): Column is used in a generated column expression and cannot be dropped.
Fix
Drop the generated column first
Drop the generated column first
ALTER TABLE t1 DROP COLUMN gen_col, DROP COLUMN base_col;
Why this works
Remove dependent generated columns before removing their source columns.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3207 ER_DEPENDENT_BY_DEFAULT_GENERATED_COLUMN
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev