MySQL does not have a default sorting. If the sorting is not specified, the order of data returned by multiple queries may be different. http://stackoverflow.com/ques...
You can use the COLLATE keyword to specify the sorting rules when building a MySQL database or table. For example, WordPress:
数据库:
CREATE DATABASE IF NOT EXISTS `wordpress`
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci;
评论表:
CREATE TABLE IF NOT EXISTS `wp_comments` (
`comment_ID` bigint(20) unsigned NOT NULL,
`comment_post_ID` bigint(20) unsigned NOT NULL DEFAULT '0',
`comment_author` text COLLATE utf8mb4_unicode_ci NOT NULL,
`comment_author_email` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`comment_author_url` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`comment_author_IP` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`comment_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`comment_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`comment_content` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
`comment_karma` int(11) NOT NULL DEFAULT '0',
`comment_approved` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '1',
`comment_agent` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`comment_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`comment_parent` bigint(20) unsigned NOT NULL DEFAULT '0',
`user_id` bigint(20) unsigned NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
The sorting rule utf8_general_ci in MySQL is not case sensitive, and ci is the abbreviation of case insensitive, that is, it is not case sensitive. For example, if the primary key content is A, inserting a will not be allowed, but searching for a can find A. That is, A and a are treated as the same in character judgment. Collation rules specify the rules for sorting and comparing string data according to the standards of a specific language and locale.
The concept of sorting rules, taking PHP’s intl extension as an example:
MySQL does not have a default sorting. If the sorting is not specified, the order of data returned by multiple queries may be different. http://stackoverflow.com/ques...
PG also has no default sorting, and the return order is unreliable if the sorting is not specified
I am the official wiki
This article introduces the Chinese character sorting of PG, MySQL, and Oracle, which may be of some reference: http://mp.weixin.qq.com/s?__b...
You can use the COLLATE keyword to specify the sorting rules when building a MySQL database or table.
For example, WordPress:
The sorting rule utf8_general_ci in MySQL is not case sensitive, and ci is the abbreviation of case insensitive, that is, it is not case sensitive.
For example, if the primary key content is A, inserting a will not be allowed, but searching for a can find A. That is, A and a are treated as the same in character judgment.
Collation rules specify the rules for sorting and comparing string data according to the standards of a specific language and locale.
The concept of sorting rules, taking PHP’s intl extension as an example: