1364ERRORTier 1 — Safe✅ HIGH confidenceField doesn't have a default value
🔴 Production Risk Error
HIGH — inserts fail in strict mode; silent data corruption in non-strict mode.
What this means
Error 1364 (SQLSTATE HY000) is returned when an INSERT statement omits a column that is NOT NULL and has no DEFAULT value. In strict SQL mode (STRICT_TRANS_TABLES) this is a hard error; in non-strict mode it may generate a warning and insert the implicit default for the type.
Why it happens
- 1INSERT statement omits a required NOT NULL column with no DEFAULT
- 2Application code does not include all required fields in the INSERT
- 3Schema changed (column added as NOT NULL with no DEFAULT) but application was not updated
How to reproduce
Inserting a row without a required column.
CREATE TABLE employees (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
department VARCHAR(50) NOT NULL -- no DEFAULT
);
INSERT INTO employees (name) VALUES ('Ana');
-- 'department' is requiredFix 1: Include the missing column in the INSERT
When the value is known at insert time.
INSERT INTO employees (name, department) VALUES ('Ana', 'Engineering');Why this works
Always list all NOT NULL columns without defaults explicitly in INSERT statements.
Fix 2: Add a DEFAULT value to the column
When a sensible default exists for the column.
ALTER TABLE employees
MODIFY department VARCHAR(50) NOT NULL DEFAULT 'Unassigned';Why this works
Adding a DEFAULT allows INSERT statements that omit the column to succeed.
Fix 3: Make the column nullable
When the value may legitimately be unknown at insert time.
ALTER TABLE employees
MODIFY department VARCHAR(50) NULL DEFAULT NULL;Why this works
Nullable columns accept NULL when omitted from an INSERT, which is semantically cleaner than a sentinel default like 'Unassigned'.
What not to do
Disable strict mode to suppress this error
Why it's wrong: Non-strict mode inserts implicit type defaults (empty string, 0) that corrupt data.
Sources
📚 Official docs: https://mariadb.com/kb/en/insert/
🔧 Source ref: MariaDB Server error code 1364 / ER_NO_DEFAULT_FOR_FIELD
📖 Further reading: MariaDB INSERT
📖 Further reading: MariaDB NOT NULL Constraint
Confidence assessment
✅ HIGH confidence
Stable.
See also
🔗 Related errors
📄 Reference pages