1364ERRORTier 1 — Safe✅ HIGH confidence

Field doesn't have a default value

Category: Data IntegrityVersions: All MariaDB / MySQL versions

🔴 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

  1. 1INSERT statement omits a required NOT NULL column with no DEFAULT
  2. 2Application code does not include all required fields in the INSERT
  3. 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.

trigger — this will ERROR
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 required
ERROR 1364 (HY000): Field 'department' doesn't have a default value

Fix 1: Include the missing column in the INSERT

When the value is known at insert time.

fix
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.

fix
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.

fix
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

📄 Reference pages

NOT NULL constraintDEFAULTstrict SQL mode
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →