Common utf8mb4 sorting rules in MySQL are:
When the default character set of a table is set to utf8mb4 but the collation is not explicitly specified:
Because the utf8mb4_0900_ai_ci collation is the collation introduced in MySQL 8.0, when you import a MySQL 8.0 table into MySQL 5.7 or MySQL 5.6, the character set may not be recognized.
Parameter ControlIn MySQL version 5.6, the collation_server parameter is used to set the default collation at the server level.
The character_set_database and collation_database parameters are deprecated in MySQL 5.7 and will be removed in a subsequent version.
Comparison between utf8mb4_unicode_ci and utf8mb4_general_ci1. Accuracy
2. Performance
Supplement: MySQL--utf8mb4 and equal value query test Test Scripts ## Delete the test table DROP TABLE IF EXISTS tb2001; DROP TABLE IF EXISTS tb2002; DROP TABLE IF EXISTS tb2003; ## Create a test table CREATE TABLE tb2001( id INT AUTO_INCREMENT PRIMARY KEY, c1 VARCHAR(100) COLLATE utf8mb4_unicode_ci, c2 VARCHAR(100) COLLATE utf8mb4_bin )ENGINE=INNODB DEFAULT CHARSET=utf8mb4 ; CREATE TABLE tb2002( id INT AUTO_INCREMENT PRIMARY KEY, c1 VARCHAR(100) COLLATE utf8mb4_general_ci, c2 VARCHAR(100) COLLATE utf8mb4_bin )ENGINE=INNODB DEFAULT CHARSET=utf8mb4; CREATE TABLE tb2003( id INT AUTO_INCREMENT PRIMARY KEY, c1 VARCHAR(100) COLLATE utf8mb4_0900_ai_ci, c2 VARCHAR(100) COLLATE utf8mb4_bin )ENGINE=INNODB DEFAULT CHARSET=utf8mb4; ## Insert test data INSERT INTO tb2001(c1,c2) ββVALUES(0xF09F8D83,0xF09F8D83),(0xF09FA68A,0xF09FA68A),(0xF09F8CA0,0xF09F8CA0); INSERT INTO tb2002(c1,c2)VALUES(0xF09F8D83,0xF09F8D83),(0xF09FA68A,0xF09FA68A),(0xF09F8CA0,0xF09F8CA0); INSERT INTO tb2003(c1,c2)VALUES(0xF09F8D83,0xF09F8D83),(0xF09FA68A,0xF09FA68A),(0xF09F8CA0,0xF09F8CA0); ## Equivalence query test SELECT * FROM tb2001 WHERE c1=0xF09F8D83; SELECT * FROM tb2002 WHERE c1=0xF09F8D83; SELECT * FROM tb2003 WHERE c1=0xF09F8D83; SELECT * FROM tb2001 WHERE c2=0xF09F8D83; SELECT * FROM tb2002 WHERE c2=0xF09F8D83; SELECT * FROM tb2003 WHERE c2=0xF09F8D83; Test Results mysql> SELECT * FROM tb2001 WHERE c1=0xF09F8D83; +----+------+------+ | id | c1 | c2 | +----+------+------+ | 1 | π | π | | 2 | π¦ | π¦ | | 3 | π | π | +----+------+------+ 3 rows in set (0.00 sec) mysql> SELECT * FROM tb2002 WHERE c1=0xF09F8D83; +----+------+------+ | id | c1 | c2 | +----+------+------+ | 1 | π | π | | 2 | π¦ | π¦ | | 3 | π | π | +----+------+------+ 3 rows in set (0.01 sec) mysql> SELECT * FROM tb2003 WHERE c1=0xF09F8D83; +----+------+------+ | id | c1 | c2 | +----+------+------+ | 1 | π | π | +----+------+------+ 1 row in set (0.00 sec) mysql> mysql> SELECT * FROM tb2001 WHERE c2=0xF09F8D83; +----+------+------+ | id | c1 | c2 | +----+------+------+ | 1 | π | π | +----+------+------+ 1 row in set (0.00 sec) mysql> SELECT * FROM tb2002 WHERE c2=0xF09F8D83; +----+------+------+ | id | c1 | c2 | +----+------+------+ | 1 | π | π | +----+------+------+ 1 row in set (0.00 sec) mysql> SELECT * FROM tb2003 WHERE c2=0xF09F8D83; +----+------+------+ | id | c1 | c2 | +----+------+------+ | 1 | π | π | +----+------+------+ 1 row in set (0.00 sec) Test Summary
This is the end of this article about utf8mb4 sorting rules in MySQL. For more information about MySQL utf8mb4 sorting, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Perfect solution for JavaScript front-end timeout asynchronous operation
>>: How to modify the default submission method of the form
Recently, when using select query in a project, I...
Linux virtual machine: VMware + Ubuntu 16.04.4 Wi...
Preface [root@localhost ~]# cat /etc/fstab # # /e...
Table of contents The relationship between the co...
In the previous article, we learned about the net...
1. Installation Instructions Compared with local ...
Experimental environment: 1. Three CentOS 7 serve...
HTTP Header Explanation 1. Accept: Tells the web s...
This article shares the specific code for JavaScr...
This article example shares the specific code of ...
Table of contents 1. Why Redux 2. Redux Data flow...
Table of contents 1. Basic use 2. Several points ...
This article summarizes the knowledge points of M...
Table of contents Preface Solution: Step 1 Step 2...
DML operations refer to operations on table recor...