MySQL 8.4Lab-verified · 2026-12-01

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

An INSERT left out a NOT NULL column that has no default value.

MySQL 8.4.13
1364 (HY000): Field 'name' doesn't have a default value

Jump to a cause

  1. 01The INSERT leaves out a NOT NULL column
  2. 02A NOT NULL column was added later without a default
  3. 03A TEXT column is NOT NULL with no default
  4. 04The primary key id column has no AUTO_INCREMENT
  5. 05created_at is NOT NULL without DEFAULT CURRENT_TIMESTAMP
  6. 06An UPDATE fires a trigger whose log-table INSERT misses a column

Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-12-01 · container image mysql:8.4

When an INSERT does not list a column, MySQL fills it with the column default. If the column is NOT NULL and has no default, strict mode (the 8.4 default) stops the INSERT with ERROR 1364 and names the column.

The message stays in English even with Korean or Japanese lc_messages. Below are six causes verified on MySQL 8.4.

01The INSERT leaves out a NOT NULL column

users.name is NOT NULL, but INSERT INTO users (email) VALUES ('a@x.com') gives only email. The error names the missing column: 'name'.

Setup
Setuprun as lab_a
CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, email VARCHAR(100) NOT NULL, name VARCHAR(50) NOT NULL);
OUTPUT
Query OK, 0 rows affected (0.01 sec)
Reproducerun as lab_a
INSERT INTO users (email) VALUES ('a@x.com');
✕ ERROR
ERROR 1364 (HY000): Field 'name' doesn't have a default value
Checkrun as lab_a
SELECT column_name, is_nullable, column_default FROM information_schema.columns WHERE table_schema = 'lab_a' AND table_name = 'users' ORDER BY ordinal_position;
OUTPUT
+-------------+-------------+----------------+
| COLUMN_NAME | IS_NULLABLE | COLUMN_DEFAULT |
+-------------+-------------+----------------+
| id          | NO          | NULL           |
| email       | NO          | NULL           |
| name        | NO          | NULL           |
+-------------+-------------+----------------+
3 rows in set (0.00 sec)

information_schema.columns shows name with IS_NULLABLE = NO and COLUMN_DEFAULT = NULL, so a value is required. Add the column to the INSERT: INSERT INTO users (email, name) VALUES ('a@x.com', 'Kim') succeeds.

After the fixrun as lab_a
INSERT INTO users (email, name) VALUES ('a@x.com', 'Kim');
SELECT id, email, name FROM users;
✓ SUCCESS
Query OK, 1 row affected (0.00 sec)

+----+---------+------+
| id | email   | name |
+----+---------+------+
|  1 | a@x.com | Kim  |
+----+---------+------+
1 row in set (0.00 sec)

02A NOT NULL column was added later without a default

ALTER TABLE orders ADD COLUMN status VARCHAR(10) NOT NULL succeeded on a table with data, but the old INSERT INSERT INTO orders (amount) VALUES (200) does not know about status and now fails.

Setup
Setuprun as lab_a
CREATE TABLE orders (id INT AUTO_INCREMENT PRIMARY KEY, amount INT NOT NULL);
INSERT INTO orders (amount) VALUES (100);
ALTER TABLE orders ADD COLUMN status VARCHAR(10) NOT NULL;
OUTPUT
Query OK, 0 rows affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0
Reproducerun as lab_a
INSERT INTO orders (amount) VALUES (200);
✕ ERROR
ERROR 1364 (HY000): Field 'status' doesn't have a default value
Checkrun as lab_a
SELECT id, amount, status FROM orders;
OUTPUT
+----+--------+--------+
| id | amount | status |
+----+--------+--------+
|  1 |    100 |        |
+----+--------+--------+
1 row in set (0.00 sec)
Fixrun as lab_a
ALTER TABLE orders ALTER COLUMN status SET DEFAULT 'NEW';
OUTPUT
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

The existing row got an empty string in status. Give the column a default so old code keeps working: ALTER TABLE orders ALTER COLUMN status SET DEFAULT 'NEW'. The same INSERT then succeeds and the new row has NEW.

After the fixrun as lab_a
INSERT INTO orders (amount) VALUES (200);
SELECT id, amount, status FROM orders ORDER BY id;
✓ SUCCESS
Query OK, 1 row affected (0.01 sec)

+----+--------+--------+
| id | amount | status |
+----+--------+--------+
|  1 |    100 |        |
|  2 |    200 | NEW    |
+----+--------+--------+
2 rows in set (0.00 sec)

03A TEXT column is NOT NULL with no default

posts.body is TEXT NOT NULL. The INSERT gives only title, so body has no value and the error names 'body'.

Setup
Setuprun as lab_a
CREATE TABLE posts (id INT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(100) NOT NULL, body TEXT NOT NULL);
OUTPUT
Query OK, 0 rows affected (0.02 sec)
Reproducerun as lab_a
INSERT INTO posts (title) VALUES ('hello');
✕ ERROR
ERROR 1364 (HY000): Field 'body' doesn't have a default value
Fixrun as lab_a
ALTER TABLE posts MODIFY body TEXT NOT NULL DEFAULT ('');
OUTPUT
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

In MySQL 8.0.13 and later a TEXT column can take an expression default written in parentheses: ALTER TABLE posts MODIFY body TEXT NOT NULL DEFAULT (''). After that the INSERT with only title succeeds and body is an empty string.

After the fixrun as lab_a
INSERT INTO posts (title) VALUES ('hello');
SELECT id, title, body = '' AS body_empty FROM posts;
✓ SUCCESS
Query OK, 1 row affected (0.01 sec)

+----+-------+------------+
| id | title | body_empty |
+----+-------+------------+
|  1 | hello |          1 |
+----+-------+------------+
1 row in set (0.00 sec)

04The primary key id column has no AUTO_INCREMENT

The INSERT left out id and only gave name, and MySQL said Field 'id' doesn't have a default value. The table was created with just id INT NOT NULL PRIMARY KEY, so there was no automatic numbering. This is common for tables migrated from another database or created from a dump.

Setup
Setuprun as lab_a
CREATE TABLE members (id INT NOT NULL PRIMARY KEY, name VARCHAR(30));
INSERT INTO members VALUES (1, 'Kim');
OUTPUT
Query OK, 0 rows affected (0.01 sec)

Query OK, 1 row affected (0.00 sec)
Reproducerun as lab_a
INSERT INTO members (name) VALUES ('Lee');
✕ ERROR
ERROR 1364 (HY000): Field 'id' doesn't have a default value
Check the causerun as lab_a
SELECT column_name, column_default, is_nullable, extra
FROM information_schema.columns
WHERE table_schema = DATABASE() AND table_name = 'members' AND column_name = 'id';
OUTPUT
+-------------+----------------+-------------+-------+
| COLUMN_NAME | COLUMN_DEFAULT | IS_NULLABLE | EXTRA |
+-------------+----------------+-------------+-------+
| id          | NULL           | NO          |       |
+-------------+----------------+-------------+-------+
1 row in set (0.00 sec)

For id, COLUMN_DEFAULT is NULL, IS_NULLABLE is NO, and EXTRA is empty. Without auto_increment in EXTRA, the value must be supplied by you.

Fixrun as lab_a
ALTER TABLE members MODIFY id INT NOT NULL AUTO_INCREMENT;
OUTPUT
Query OK, 1 row affected (0.03 sec)
Records: 1  Duplicates: 0  Warnings: 0

After ALTER TABLE members MODIFY id INT NOT NULL AUTO_INCREMENT; the same INSERT worked and got id 2, right after the existing row 1.

After the fixrun as lab_a
INSERT INTO members (name) VALUES ('Lee');
SELECT * FROM members ORDER BY id;
✓ SUCCESS
Query OK, 1 row affected (0.01 sec)

+----+------+
| id | name |
+----+------+
|  1 | Kim  |
|  2 | Lee  |
+----+------+
2 rows in set (0.00 sec)

05created_at is NOT NULL without DEFAULT CURRENT_TIMESTAMP

The timestamp column created_at DATETIME NOT NULL had no default. An INSERT that only passed amount, with no time from the application, failed with 1364.

Setup
Setuprun as lab_a
CREATE TABLE orders (id INT AUTO_INCREMENT PRIMARY KEY, amount INT, created_at DATETIME NOT NULL);
OUTPUT
Query OK, 0 rows affected (0.01 sec)
Reproducerun as lab_a
INSERT INTO orders (amount) VALUES (100);
✕ ERROR
ERROR 1364 (HY000): Field 'created_at' doesn't have a default value
Fixrun as lab_a
ALTER TABLE orders MODIFY created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;
OUTPUT
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

Adding DEFAULT CURRENT_TIMESTAMP made the same INSERT work, and created_at was filled in automatically (has_time = 1).

After the fixrun as lab_a
INSERT INTO orders (amount) VALUES (100);
SELECT id, amount, created_at IS NOT NULL AS has_time FROM orders;
✓ SUCCESS
Query OK, 1 row affected (0.00 sec)

+----+--------+----------+
| id | amount | has_time |
+----+--------+----------+
|  1 |    100 |        1 |
+----+--------+----------+
1 row in set (0.00 sec)

06An UPDATE fires a trigger whose log-table INSERT misses a column

Only the price in products was updated, yet MySQL said Field 'changed_by' doesn't have a default value, and products has no changed_by column. The trigger that logs price changes inserted into price_log without the NOT NULL changed_by column.

The message does not name the table, so if it mentions a column that is not in your statement, suspect a trigger. When the trigger fails, the original UPDATE is cancelled too.

Setup
Setuprun as root
CREATE TABLE lab_a.products (id INT PRIMARY KEY, price INT);
CREATE TABLE lab_a.price_log (id INT AUTO_INCREMENT PRIMARY KEY, product_id INT NOT NULL, old_price INT, new_price INT, changed_by VARCHAR(50) NOT NULL);
INSERT INTO lab_a.products VALUES (1, 1000);
CREATE TRIGGER lab_a.trg_price_log AFTER UPDATE ON lab_a.products FOR EACH ROW
  INSERT INTO lab_a.price_log (product_id, old_price, new_price) VALUES (OLD.id, OLD.price, NEW.price);
OUTPUT
Query OK, 0 rows affected (0.02 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)
Reproducerun as lab_a
UPDATE products SET price = 1200 WHERE id = 1;
✕ ERROR
ERROR 1364 (HY000): Field 'changed_by' doesn't have a default value
Check the causerun as lab_a
SELECT trigger_name, event_object_table, action_statement
FROM information_schema.triggers WHERE trigger_schema = DATABASE();
OUTPUT
+---------------+--------------------+------------------------------------------------------------------------------------------------------+
| TRIGGER_NAME  | EVENT_OBJECT_TABLE | ACTION_STATEMENT                                                                                     |
+---------------+--------------------+------------------------------------------------------------------------------------------------------+
| trg_price_log | products           | INSERT INTO lab_a.price_log (product_id, old_price, new_price) VALUES (OLD.id, OLD.price, NEW.price) |
+---------------+--------------------+------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

The ACTION_STATEMENT of trg_price_log on products inserts into price_log without changed_by in its column list.

Fixrun as root
DROP TRIGGER lab_a.trg_price_log;
CREATE TRIGGER lab_a.trg_price_log AFTER UPDATE ON lab_a.products FOR EACH ROW
  INSERT INTO lab_a.price_log (product_id, old_price, new_price, changed_by)
  VALUES (OLD.id, OLD.price, NEW.price, USER());
OUTPUT
Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Recreating the trigger to fill changed_by with USER() let the UPDATE succeed, and the log recorded lab_a@127.0.0.1.

After the fixrun as lab_a
UPDATE products SET price = 1200 WHERE id = 1;
SELECT product_id, old_price, new_price, changed_by FROM price_log;
✓ SUCCESS
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

+------------+-----------+-----------+-----------------+
| product_id | old_price | new_price | changed_by      |
+------------+-----------+-----------+-----------------+
|          1 |      1000 |      1200 | lab_a@127.0.0.1 |
+------------+-----------+-----------+-----------------+
1 row in set (0.00 sec)

FAQ

How do I fix Field doesn't have a default value in MySQL?

Either include that column in the INSERT, or give the column a default with ALTER TABLE ... ALTER COLUMN col SET DEFAULT ....

Why did it start failing after I added a column?

The new column is NOT NULL without a default, and INSERTs that don't list it have no value for it. Add a default to the column.

Can a TEXT column have a default value in MySQL?

Yes, as an expression in parentheses, for example DEFAULT (''). We checked it on MySQL 8.4.

Is ERROR 1364 shown in Korean or Japanese?

In our test on MySQL 8.4 the message was English even with lc_messages set to ko_KR or ja_JP.

Why do I get Field 'id' doesn't have a default value?

Usually id has no AUTO_INCREMENT. Check whether extra in information_schema.columns shows auto_increment, and if not, add it with ALTER TABLE ... MODIFY id INT NOT NULL AUTO_INCREMENT;.

I only ran an UPDATE and got 1364 for a column that is not in my table.

A trigger on that table is inserting into another table and leaving out a column. Read the trigger body in action_statement of information_schema.triggers.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13