The BINARY and VARBINARY Types Values in  CHAR ,  VARCHAR , and  TEXT  columns are sorted and compared according to the character set collation assigned to the column. MySQL collations have a pad attribute of  PAD SPACE , other than Unicode collations based on UCA 9.0.0 and higher, which have a pad attribute of  NO PAD . (see Section 10.10.1, “Unicode Character Sets” ). To determine the pad attribute for a collation, use the  INFORMATION_SCHEMA COLLATIONS  table, which has a  PAD_ATTRIBUTE  column. For nonbinary strings ( CHAR ,  VARCHAR , and  TEXT  values), the string collation pad attribute determines treatment in comparisons of trailing spaces at the end of strings.  NO PAD  collations treat trailing spaces as significant in comparisons, like any other character.  PAD SPACE  collations treat trailing spaces as insignificant in comparisons; strings are compared without regard to trailing spaces. See Trailing Space Handling in Comparisons. The server SQL mode has no effect on comparison behavior with respect to trailing spaces. For more information about MySQL character sets and collations, see Chapter 10, Character Sets, Collations, Unicode . For additional information about storage requirements, see Section 11.7, “Data Type Storage Requirements” . For those cases where trailing pad characters are stripped or comparisons ignore them, if a column has an index that requires unique values, inserting into the column values that differ only in number of trailing pad characters results in a duplicate-key error. For example, if a table contains  ’a’ , an attempt to store  ’a ’ causes a duplicate-key error. The  BINARY  and  VARBINARY  types are similar to  CHAR  and  VARCHAR , except that they store binary strings rather than nonbinary strings. That is, they store byte strings rather than character strings. This means they have the  binary  character set and collation, and comparison and sorting are based on the numeric values of the bytes in the values. The permissible maximum length is the same for  BINARY  and  VARBINARY  as it is for  CHAR  and  VARCHAR , except that the length for  BINARY  and  VARBINARY  is measured in bytes rather than characters. The  BINARY  and  VARBINARY  data types are distinct from the  CHAR BINARY  and  VARCHAR BINARY  data types. For the latter types, the  BINARY  attribute does not cause the column to be treated as a binary string column. Instead, it causes the binary ( _bin ) collation for the column character set (or the table default character set if no column character set is specified) to be used, and the column itself stores nonbinary character strings rather than binary byte strings. For example, if the default character set is  utf8mb4 , CHAR(5) BINARY  is treated as  CHAR(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin . This differs from  BINARY(5) , which stores 5-byte binary strings that have the  binary  character set and 2040 11.3.3 The BINARY and VARBINARY Types Note mysql>  CREATE TABLE vc (v VARCHAR(4), c CHAR(4)); Query OK, 0 rows affected (0.01 sec) mysql>  INSERT INTO vc VALUES (’ab ’, ’ab ’); Query OK, 1 row affected (0.00 sec) mysql>  SELECT CONCAT(’(’, v, ’)’), CONCAT(’(’, c, ’)’) FROM vc; +---------------------+---------------------+ | CONCAT(’(’, v, ’)’) | CONCAT(’(’, c, ’)’) | +---------------------+---------------------+ | (ab ) | (ab) | +---------------------+---------------------+ 1 row in set (0.06 sec)