CHAR and VARCHAR both store text, but differently: CHAR reserves fixed space and pads with spaces, VARCHAR stores only what you give it. The right pick keeps storage lean and behaviour predictable.
Key Points
- CHAR(10) always uses 10 characters of storage, space-padded
- VARCHAR(10) stores actual length + 1–2 length bytes
- CHAR suits fixed-length codes: country codes, PIN codes, flags
- VARCHAR suits names, emails, addresses — anything variable
- CHAR silently trims trailing spaces on retrieval — a classic gotcha
- Modern default: VARCHAR almost everywhere; CHAR for true fixed-width data
.png)