1966
MariaDBWARNINGNotableDataHIGH confidence
Incorrect value for column
Production Risk
Medium — data may be silently truncated in non-strict mode.
What this means
A value being inserted or updated was truncated or converted because it does not fit the column's data type or length constraints. In strict mode this becomes an error.
Why it happens
- 1Inserting a string longer than the column's VARCHAR or CHAR length.
- 2Inserting a non-numeric string into a numeric column.
- 3Date/time values outside the valid range for the column type.
How to reproduce
trigger — this will error
trigger — this will error
INSERT INTO t (code) VALUES ('TOOLONGVALUE'); -- code is CHAR(5)expected output
Warning 1366: Incorrect string value: 'TOOLONGVALUE' for column 'code' at row 1
Fix 1
Truncate or correct the data before inserting
Truncate or correct the data before inserting
INSERT INTO t (code) VALUES (LEFT('TOOLONGVALUE', 5));Why this works
Ensure values conform to column length and type constraints before insertion.
Fix 2
Widen the column to accommodate the data
Widen the column to accommodate the data
ALTER TABLE t MODIFY code CHAR(20);
Why this works
Increase the column size if the longer values are valid data.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 1966 ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev