Differences between CHAR and VARCHAR : Char Varchar « Data Types « MySQL Tutorial






ValueCHAR(4)Storage RequiredVARCHAR(4)Storage Required
''' '4 bytes''1 byte
'ab''ab '4 bytes'ab'3 bytes
'abcd''abcd'4 bytes'abcd'5 bytes
'abcdefgh''abcd'4 bytes'abcd'5 bytes










10.5.Char Varchar
10.5.1.CHAR and VARCHAR
10.5.2.Differences between CHAR and VARCHAR
10.5.3.Set column default value for VARCHAR
10.5.4.VARCHAR column with default value
10.5.5.All CHAR and VARCHAR values in MySQL are compared without regard to any trailing spaces
10.5.6.If a given value is stored into the CHAR(4) and VARCHAR(4) columns, the trailing spaces of values retrieved from the columns are removed from CHAR columns.