What is the difference between CHAR and VARCHAR in MySQL?

PointCHAR(n)VARCHAR(n)
LengthFixed. Always n characters, paddedVariable, up to n characters
SpaceAlways nOnly the text length (plus 1 or 2 bytes)
Best forValues of the same length: country code, PINNames, emails, titles
country_code CHAR(2),       -- IN, US, UK
name         VARCHAR(100)    -- any name up to 100 characters

Use VARCHAR for most text. See MySQL Data Types.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.