1265
MariaDBWARNINGCommonData IntegrityHIGH confidence

Data truncated for column

Production Risk

HIGH — silent data corruption if warnings are not checked.

What this means

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.

Why it happens
  1. 1Inserting a string value into an ENUM column that does not match any ENUM member
  2. 2Inserting a DECIMAL value with more fractional digits than the column definition allows
  3. 3Inserting a value into a SET column that is not a recognised member
  4. 4String value exceeds column length when strict mode is off (truncated silently)
How to reproduce

Inserting an invalid ENUM value with strict mode disabled.

trigger — this will error
trigger — this will error
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.

Enable strict SQL mode to make truncation a hard error
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.

Fix the source data to match the column definition
-- 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.

What not to do

Ignore 1265 warnings in non-strict mode

Silent truncation leads to corrupted data that is difficult to detect and correct later.

Version notes
MariaDB 10.2.4+

Strict mode is enabled by default in new installations.

Sources
Official documentation ↗

MariaDB Server error code 1265 / WARN_DATA_TRUNCATED

MariaDB SQL ModesMariaDB ENUM

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors