DBAtlas · Database operations atlas

1364: Field 'name' doesn't have a default value

MySQL

What does it mean?

A row was inserted without a value for a column defined as NOT NULL with no DEFAULT. In strict SQL mode MySQL raises an error because it cannot fill in the missing required column automatically.

Why does it happen?

A required (NOT NULL, no DEFAULT) column was omitted from the INSERT, and STRICT_TRANS_TABLES/STRICT_ALL_TABLES is enabled in sql_mode. An application written for the old, permissive mode hits this error when moved to a server with strict mode enabled.

How to fix it

Add a value for the missing column to the INSERT, or define a sensible DEFAULT on the column: ALTER TABLE my_table MODIFY my_column ... NOT NULL DEFAULT 'value'; If the column really is optional, allow NULL. sql_mode can be relaxed as a temporary/compatibility workaround, but keeping strict mode is recommended for data quality.

Open in DBAtlas →

More from this engine