MySQL error 1265: Data truncated for column
A value was cut or adjusted to fit the column. It's usually a warning in non-strict mode; in strict mode, or for some values, the statement fails.
- Error number
1265- Name
WARN_DATA_TRUNCATED- SQLSTATE
01000- Category
- Data values
What it means
1265 (SQLSTATE 01000, a warning class) means MySQL changed the value to store it: a string cut to the column length, an ENUM value that isn't in the list stored as '', or decimals rounded. Check SHOW WARNINGS after the statement. In strict mode, many of these cases are errors instead.
Common causes
- A value not in an
ENUMorSETcolumn's list. - A string longer than the column in non-strict mode.
- An empty string into a numeric or date column.
ALTER TABLEthat shortens a column holding longer values.
How to fix it
-
See exactly what was changed.
SHOW WARNINGS;
-
For
ENUMcolumns, add the value to the list or map it before inserting.ALTER TABLE orders MODIFY status ENUM('new', 'paid', 'shipped', 'cancelled') NOT NULL; -
Before shortening a column, find values that wouldn't fit.
SELECT id, CHAR_LENGTH(name) FROM customers WHERE CHAR_LENGTH(name) > 50;
Related errors
More data values errors
The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.
Work on MySQL in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.