1293
MySQLerrorddlhigh confidence
Invalid default value for column
Production Risk
Low — DDL fails; no data affected.
What this means
The DEFAULT value specified for a column is not valid for the column's data type or violates a constraint.
Why it happens
- 1DEFAULT value exceeds the column's range or length
- 2Non-deterministic expression used as DEFAULT on MySQL < 8.0
- 3Specifying DEFAULT NULL on a NOT NULL column
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (dt DATE DEFAULT 'not-a-date');
expected output
ERROR 1293 (42000): Invalid default value for 'dt'
Fix 1
Use a valid literal default
Use a valid literal default
CREATE TABLE t (dt DATE DEFAULT '2000-01-01');
Why this works
Ensure the default value is a valid literal for the column type.
Fix 2
Use expression defaults (MySQL 8.0+)
Use expression defaults (MySQL 8.0+)
CREATE TABLE t (created_at DATETIME DEFAULT (NOW()));
Why this works
MySQL 8.0 allows expressions in DEFAULT clauses.
What not to do
✕
Version notes
Sources
Official documentation ↗
MySQL 8.0 — 1293 ER_INVALID_DEFAULT
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev