Invalid default value for column
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.
- 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
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 );
expected output
ERROR 1067 (42000): Invalid default value for 'event_date'
Fix 1
Use a valid literal default for DATE columns
WHEN 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 logic
Why 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 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.
✕ Disable strict SQL mode to work around this
Strict mode protects data integrity; disabling it masks real data type mismatches.
Expression defaults (parenthesised expressions) are supported, allowing DEFAULT (CURRENT_DATE), DEFAULT (UUID()), etc.
Expression defaults also supported.
MariaDB Server error code 1067 / ER_INVALID_DEFAULT
MariaDB DEFAULT Column Option ↗MariaDB Expression Defaults ↗Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev