MySQL minimum CHAR storage for constant strings -
i have simple table has 2 values: id
, type
. longest string in type
11 characters ("directorate").
should using char(11)
or char(12)
in create
command? mysql store 12 bytes char(11)
12th byte null character or not relevant storage?
edit: joni pointed out, not use 11 or 12 bytes, uses 33 or 36 bytes because storing utf-8. however, question if should using 11 or 12 in char(x)
the storage required char(m)
m × w bytes, 0 <= m <= 255, w number of bytes required maximum-length character in character set.
(source: https://dev.mysql.com/doc/refman/5.6/en/storage-requirements.html)
that is, if use ascii
or other single byte encoding, char(m)
stored in m bytes. if use utf8
stored in 3*m bytes.
Comments
Post a Comment