MENU
Data Types String
Character Type |
CHAR(10), for example, can hold up to 10 characters. 10 bytes are used regardless of how long the string is. VARCHAR(10), for example, can hold up to 10 characters. The number of bytes used equals the length of the string plus one or two bytes. |
BINARY(10) and VARBINARY(10) are similar to CHAR(10) and VARCHAR(10), except that the former types contain byte strings rather than character strings. Without using any character sets, BINARY(n) and VARBINARY(n) perform sorting and comparison based on the numeric values of the bytes. |
CHAR(10) BINARY and VARCHAR(10) BINARY use the binary collations for the column character sets. |
Text Type | Storage Required |
TINYBLOB, TINYTEXT | L+1 bytes, L <28 |
BLOB, TEXT | L+2 bytes, L <216 |
MEDIUMBLOB, MEDIUMTEXT | L+3 bytes, L <224 |
LONGBLOB, LONG TEXT | L+4 bytes, L <232 |
Where L is the number of bytes of the string. | |
BLOB values are regarded as byte strings. TEXT values are regarded as character strings. |
Custom Type |
ENUM(‘cat’, ‘dog’), for instance, can contain the values NULL, ‘’, ‘cat’, and ‘dog’. Each predefined value equals an integer, starting with 1. 0 is reserved for the empty string. Using ENUM() saves storage space. |
SET(‘cat’,’dog’), for instance, can contain the values NULL, ‘’, ‘cat’, ‘dog’ and ‘cat,dog’. Multiple members are separated by commas. A maximum of 64 members are allowed. In this case, ‘cat’ has a binary value of 01 while ‘dog’ has a binary value of 10. |