What is the difference between CHAR and VARCHAR?

Answer

CHAR(n) is a fixed-length character type that always stores exactly n characters, padding with spaces if the input is shorter. It uses constant storage space (good for values of known fixed length like country codes "US", "UK"). VARCHAR(n) is a variable-length type that stores only the actual characters plus a small length overhead — more space-efficient for variable-length strings. Performance: CHAR can be marginally faster for fixed-width data in some engines since row sizes are predictable. In practice, use CHAR for fixed-length codes (ISO codes, status flags) and VARCHAR for names, emails, and other variable-length strings.