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
MYSQL version: MySQL Community Server 5.7.17, ins...
Prelude We all know that nginx is an excellent re...
You may encounter the following problems when ins...
Table of contents 1. Usage 2. Output results 1.id...
Often you will encounter a style of <a> tag...
Here is a Vue single sign-on demo for your refere...
Preface Before talking about covering index, we m...
Install vsftpd $ sudo apt-get install vsftpd -y S...
The mini program collected user personal informat...
Table of contents Makefile Makefile naming and ru...
1 Background Recently, some performance issues ha...
In this article, I will explain the relevant cont...
There is no mysql by default in the yum source of...
1. Varnish Overview 1. Introduction to Varnish Va...
Table of contents Effect demonstration:Main JS co...