Differentiate between CHAR and VARCHAR in MySQL.
CHAR stores the data or values in fixed length format. If the size of the string is smaller than the specified length, it is padded with space characters to match with the length.
On the other hand, VARCHAR stores data in variable length format without any padding. One or two extra bytes are added to store the length.
Examplewe have a data type-
CHAR(4);
String abc will be stored as 4 bytes.
VARCHAR(4)
String abc will be stored in 3 bytes.