DBAtlas · Database operations atlas

1406: Data too long for column

MySQL

What does it mean?

A value longer than the column's defined maximum length was written. For example, a 20-character string does not fit into a VARCHAR(10) column.

Why does it happen?

Column width too small for the data; characters in a multibyte character set (utf8mb4) taking more space than expected; a concatenation result growing longer; strict SQL mode being active (otherwise the value is silently truncated).

How to fix it

Widen the column: ALTER TABLE my_table MODIFY my_column VARCHAR(255); For very long content, consider the TEXT type. If the value must be shortened, trim it in the application or with SUBSTRING. Find the overflowing row: SELECT * FROM my_table WHERE CHAR_LENGTH(my_column) > 10; Add input validation.

Open in DBAtlas →

More from this engine