Menu

Data Truncated for Column at Row 1 on CHAR(1): Cause and Fix
📰

Data Truncated for Column at Row 1 on CHAR(1): Cause and Fix

DEV Community: database·Faizan·27 days ago
#dd8LyFQX
#devtodatabase#devto#dev#active#column
Long article (1997 words) — no AI summary yet.
Reading 0:00
15s threshold

You add an active CHAR(1) column that's supposed to hold Y or N , run your import, and MySQL replies with Warning 1265 . Or worse, it says nothing, and a week later you find out half your rows say Y when they should say N .

If you're asking why do I get a 'Data truncated for column at row 1' warning when setting CHAR(1) for my column?, the short version is this: MySQL got a value longer than one character. Below I'll show you how to find that value, fix it, and set MySQL up so it refuses bad data instead of quietly chopping it.

Short answer: CHAR(1) holds exactly one character. When you insert something longer, like 'Yes' , 'true' , or 'Y' with a hidden \r from a Windows CSV, MySQL in non-strict mode keeps the first character and raises warning 1265. In strict mode you get an error instead. Fix the incoming value or widen the column.

Why Do I Get a 'Data Truncated for Column at Row 1' Warning When Setting CHAR(1) for My Column?

"Row 1" doesn't mean the first row of your table.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.