Data truncated for column
Production Risk
HIGH — silent data corruption if warnings are not checked.
Warning (or error in strict mode) 1265 is generated when a value being inserted or updated is silently truncated to fit the column definition — for example, a string too long for an ENUM, a decimal with too many fractional digits, or a value outside an integer range. In strict SQL mode this becomes a hard error.
- 1Inserting a string value into an ENUM column that does not match any ENUM member
- 2Inserting a DECIMAL value with more fractional digits than the column definition allows
- 3Inserting a value into a SET column that is not a recognised member
- 4String value exceeds column length when strict mode is off (truncated silently)
Inserting an invalid ENUM value with strict mode disabled.
INSERT INTO orders (status) VALUES ('shipped_today');
-- status is ENUM('pending', 'shipped', 'delivered')expected output
Query OK, 1 row affected, 1 warning (0.01 sec) -- SHOW WARNINGS: Warning | 1265 | Data truncated for column 'status' at row 1
Fix 1
Enable strict SQL mode to make truncation a hard error
WHEN In all production environments — strict mode prevents silent data corruption.
SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO'; -- Or permanently in my.cnf: -- sql_mode = STRICT_TRANS_TABLES,...
Why this works
STRICT_TRANS_TABLES causes data truncation to raise an error rather than a warning, forcing the application to send valid data.
Fix 2
Fix the source data to match the column definition
WHEN When the value being inserted is incorrect.
-- Map to a valid ENUM value before inserting:
INSERT INTO orders (status) VALUES ('shipped');
-- Or extend the ENUM to include the new value:
ALTER TABLE orders MODIFY status ENUM('pending', 'shipped', 'shipped_today', 'delivered');Why this works
Extending the ENUM is preferred when the new value is intentional; mapping is preferred when the source data has a bug.
✕ Ignore 1265 warnings in non-strict mode
Silent truncation leads to corrupted data that is difficult to detect and correct later.
Strict mode is enabled by default in new installations.
MariaDB Server error code 1265 / WARN_DATA_TRUNCATED
MariaDB SQL Modes ↗MariaDB ENUM ↗Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev