CHAR(n)
is a string of a fixed length of n
characters. If it is CHARACTER SET utf8mb4
, that means it occupies exactly 4*n
bytes, regardless of what text is in it.
Most use cases for CHAR(n)
involve strings that contain English characters, hence should be CHARACTER SET ascii
. (latin1
will do just as good.)
country_code CHAR(2) CHARACTER SET ascii,
postal_code CHAR(6) CHARACTER SET ascii,
uuid CHAR(39) CHARACTER SET ascii, -- more discussion elsewhere