content_image/770925.jpg
WHERE COLLATION_NAME LIKE ’utf8mb4%bin’; +------------------+---------------+ | COLLATION_NAME | PAD_ATTRIBUTE | +------------------+---------------+ | utf8mb4_bin | PAD SPACE | | utf8mb4_0900_bin | NO PAD | +------------------+---------------+ mysql> SET NAMES utf8mb4 COLLATE utf8mb4_bin; mysql> SELECT ’a ’ = ’a’; +------------+ | ’a ’ = ’a’ | +------------+ | 1 | +------------+ mysql> SET NAMES utf8mb4 COLLATE utf8mb4_0900_bin; mysql> SELECT ’a ’ = ’a’; +------------+ | ’a ’ = ’a’ | +------------+ | 0 | +------------+ 

<img src='content_image/770925.jpg'>

## Note 

“Comparison”  in this context does not include the LIKE  pattern-matching operator, for which trailing spaces are significant, regardless of collation. 

For binary strings ( BINARY , VARBINARY , and BLOB  values), all bytes are significant in comparisons, including trailing spaces: 

## Trailing Space Handling for Inserts and Retrievals 

mysql> SET NAMES binary; mysql> SELECT ’a ’ = ’a’; +------------+ | ’a ’ = ’a’ | +------------+ | 0 | +------------+ 

CHAR( N )  columns store nonbinary strings N  characters long. For inserts, values shorter than N  characters are extended with spaces. For retrievals, trailing spaces are removed. 

BINARY( N )  columns store binary strings N  bytes long. For inserts, values shorter than N  bytes are extended with 0x00  bytes. For retrievals, nothing is removed; a value of the declared length is always returned. 

## 10.8.6 Examples of the Effect of Collation 

mysql> CREATE TABLE t1 ( a CHAR(10) CHARACTER SET utf8 COLLATE utf8_bin, b BINARY(10) ); mysql> INSERT INTO t1 VALUES (’x’,’x’); mysql> INSERT INTO t1 VALUES (’x ’,’x ’); mysql> SELECT a, b, HEX(a), HEX(b) FROM t1; +------+------------+--------+----------------------+ | a | b | HEX(a) | HEX(b) | +------+------------+--------+----------------------+ | x | x | 78 | 78000000000000000000 | | x | x | 78 | 78200000000000000000 | +------+------------+--------+----------------------+ 

## Example 1: Sorting German Umlauts 

