← BYTES
Database·Starter·Ref: 13.1.20

What is the key practical difference between a CHAR(n) and a VARCHAR(n) column type?

Have a question about this video? Mention reference 13.1.20 when you contact us.

a.CHAR always stores exactly n characters, padding shorter values with spaces; VARCHAR stores only the actual characters given (up to n), using variable storage space based on the actual string length
b.CHAR can only store numbers while VARCHAR can store any character
c.VARCHAR columns cannot be indexed
d.There is no real difference between the two in any database engine
CHAR(n) is a fixed-width type -- a value shorter than n is padded with trailing spaces to always occupy exactly n characters of storage, which can be slightly faster for fixed-length data (like a 2-letter country code) but wastes space for variable-length text; VARCHAR(n) stores only the actual string length (plus a small length prefix), making it the more space-efficient and common choice for genuinely variable-length text.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES13120#Database