1067ERRORTier 2 — Caution✅ HIGH confidenceInvalid default value for column
What this means
Error 1067 (SQLSTATE 42000) is raised during CREATE TABLE or ALTER TABLE when a column's DEFAULT value is incompatible with its data type, violates a constraint, or is a non-deterministic function that is not permitted as a default in that context.
Why it happens
- 1DEFAULT value literal does not match the column's data type (e.g., DEFAULT 'abc' on an INT column)
- 2DEFAULT NOW() or DEFAULT CURRENT_TIMESTAMP used on a DATE column in older MySQL/MariaDB versions
- 3Strict SQL mode rejects values that would otherwise be silently coerced
- 4DATETIME column has DEFAULT '0000-00-00 00:00:00' with NO_ZERO_DATE mode active
How to reproduce
Creating a table with an invalid default value.
CREATE TABLE events (
id INT AUTO_INCREMENT PRIMARY KEY,
event_date DATE DEFAULT NOW() -- NOW() is not valid for DATE default
);Fix 1: Use a valid literal default for DATE columns
When the column type is DATE or another type that does not accept NOW().
CREATE TABLE events (
id INT AUTO_INCREMENT PRIMARY KEY,
event_date DATE DEFAULT (CURRENT_DATE) -- MariaDB 10.2.1+ expression default
);
-- Or simply omit the default and set it in application logicWhy this works
MariaDB 10.2.1+ supports expression defaults enclosed in parentheses. Older versions require a literal or NULL.
Fix 2: Replace zero-date default
When '0000-00-00' is rejected by NO_ZERO_DATE mode.
-- Change default to NULL (if column is nullable):
ALTER TABLE events MODIFY event_date DATE NULL DEFAULT NULL;Why this works
NULL is always a valid default for nullable columns and avoids zero-date issues.
What not to do
Disable strict SQL mode to work around this
Why it's wrong: Strict mode protects data integrity; disabling it masks real data type mismatches.
Version notes
MariaDB 10.2.1+Expression defaults (parenthesised expressions) are supported, allowing DEFAULT (CURRENT_DATE), DEFAULT (UUID()), etc.MySQL 8.0.13+Expression defaults also supported.Sources
📚 Official docs: https://mariadb.com/kb/en/create-table/#default-column-option
🔧 Source ref: MariaDB Server error code 1067 / ER_INVALID_DEFAULT
📖 Further reading: MariaDB DEFAULT Column Option
📖 Further reading: MariaDB Expression Defaults
Confidence assessment
✅ HIGH confidence
Stable. Expression default support version boundaries are well documented.
See also
📄 Reference pages