1265WARNINGTier 1 — Safe✅ HIGH confidence

Data truncated for column

Category: Data IntegrityVersions: All MariaDB / MySQL versions

🔴 Production Risk Error

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
INSERT INTO orders (status) VALUES ('shipped_today');
-- status is ENUM('pending', 'shipped', 'delivered')
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

In all production environments — strict mode prevents silent data corruption.

fix
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 the value being inserted is incorrect.

fix
-- 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

Why it's wrong: 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 docs: https://mariadb.com/kb/en/sql-mode/#strict-mode

🔧 Source ref: MariaDB Server error code 1265 / WARN_DATA_TRUNCATED

📖 Further reading: MariaDB SQL Modes

📖 Further reading: MariaDB ENUM

Confidence assessment

✅ HIGH confidence

Stable.

See also

📄 Reference pages

ENUMstrict SQL modeSHOW WARNINGS
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →