1364
MariaDBERRORCommonData IntegrityHIGH confidence

Field doesn't have a default value

Production Risk

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

expected output

ERROR 1364 (HY000): Field 'department' doesn't have a default value

Fix 1

Include the missing column in the INSERT

WHEN When the value is known at insert time.

Include the missing column in the INSERT
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 When a sensible default exists for the column.

Add a DEFAULT value to 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 When the value may legitimately be unknown at insert time.

Make the column nullable
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

Non-strict mode inserts implicit type defaults (empty string, 0) that corrupt data.

Sources
Official documentation ↗

MariaDB Server error code 1364 / ER_NO_DEFAULT_FOR_FIELD

MariaDB INSERTMariaDB NOT NULL Constraint

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors