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






VARCHAR is a variable length and the CHAR is not.

CHAR types are used for fixed lengths.

If you declare a CHAR(10), all values stored in this column will be 10 bytes long, even if it is only 3 characters long.

MySQL pads this value to fit the size that was declared.









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.