MySQL & MariaDB error 1265: Data truncated for column
Data truncated for column 'sdate' at row 1 (5.6.51) A value had to be cut or replaced to fit the column: an unknown ENUM value, a string into a number column, or too many decimals. An error in strict mode, a warning otherwise.
| MySQL | MariaDB | |
|---|---|---|
| Symbol | WARN_DATA_TRUNCATED | WARN_DATA_TRUNCATED |
| SQLSTATE | 01000 | 01000 |
| Type | Server error | Server error |
| Versions | every release since 5.0 active | every release since 5.5 active |
What it means
The server couldn’t store the value as given. In strict mode it refuses the row; without strict mode it stores a converted value (an empty string for an invalid ENUM, the leading digits of '12abc' in an INT) and raises warning 1265.
Why it happens
- A value that isn’t in an
ENUMorSETlist, often a new option the application started sending before the schema was changed. - A string that isn’t fully numeric into a numeric column (
'1,200','12 kg'). Some of these give 1366 instead. ALTER TABLE … MODIFYto a smaller or different type when existing rows don’t fit.LOAD DATAwith the wrong field separator, so a whole line lands in the first column.- Rounding extra decimals in a
DECIMALcolumn raises only a note 1265, which is not an error even in strict mode.
How to fix it
- For
ENUM, add the new value. Append it at the end of the list, so stored values keep their internal index and the change doesn’t need a table rebuild. - Clean the data before inserting (strip units and thousands separators), or use a column type that matches the data.
- Before an
ALTER TABLEthat narrows a column, find rows that won’t fit, e.g.SELECT … WHERE CHAR_LENGTH(col) > 20.
Reproduce it yourself
These steps are the exact test our harness runs. Use a scratch server, never production.
Connect with
mysql -u root -pand create a scratch database and the test data:CREATE DATABASE demo; USE demo; CREATE TABLE t (size ENUM('S','M','L'));Run:
SET SESSION sql_mode = 'STRICT_TRANS_TABLES'; INSERT INTO t VALUES ('XL');
You get: Data truncated for column 'size' at row 1(11.8.9)
Verified fixes
Add the value to the column definition (append it at the end so existing values keep their index)
SET SESSION sql_mode = 'STRICT_TRANS_TABLES'; ALTER TABLE t MODIFY size ENUM('S','M','L','XL'); INSERT INTO t VALUES ('XL'); SELECT size FROM t;
Tested on
| Step | MySQL | MariaDB | |||||||
|---|---|---|---|---|---|---|---|---|---|
| 5.6 | 5.7 | 8.0 | 8.4 | 9 | 10.6 | 10.11 | 11.4 | 11.8 | |
| Insert a value that isn't in the ENUM list, in strict mode repro | ✓ 1265 | ✓ 1265 | ✓ 1265 | ✓ 1265 | ✓ 1265 | ✓ 1265 | ✓ 1265 | ✓ 1265 | ✓ 1265 |
| Without strict mode the row is stored with an empty string (warning 1265) version check | ⚠ 1265 | ⚠ 3090,1265 | ⚠ 1265 | ⚠ 1265 | ⚠ 1265 | ⚠ 1265 | ⚠ 1265 | ⚠ 1265 | ⚠ 1265 |
| Add the value to the column definition (append it at the end so existing values keep their index) fix | ✓ | ⚠ 3135,3090 | ⚠ 3135 | ⚠ 3135 | ⚠ 3135 | ✓ | ✓ | ✓ | ✓ |
What the warnings and failures say (4)
- Without strict mode the row is stored with an empty string (warning 1265) (MySQL 5.6, MySQL 8.0, MySQL 8.4, MySQL 9, MariaDB 10.6, MariaDB 10.11, MariaDB 11.4, MariaDB 11.8): warning 1265: Data truncated for column 'size' at row 1
- Without strict mode the row is stored with an empty string (warning 1265) (MySQL 5.7): warning 3090: Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.; warning 1265: Data truncated for column 'size' at row 1
- Add the value to the column definition (append it at the end so existing values keep their index) (MySQL 5.7): warning 3135: 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with stric; warning 3090: Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
- Add the value to the column definition (append it at the end so existing values keep their index) (MySQL 8.0, MySQL 8.4, MySQL 9): warning 3135: 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with stric
Related errors
Where this error shows up in our guides
- LOAD DATA INFILE variable data · Date in the wrong format without SET conversion MySQL 5.6
- Remove NOT NULL constraint from a table · MODIFY ... NOT NULL while NULLs exist (5.6 non-strict silently turns NULL into '' with warning 1265) MySQL 5.6MariaDB 10.6 10.11 11.4 11.8