1、gbk_chinese_ci和 gbk_bin:如果设置为 gbk_chinese_ci,表数据包括索引判断不区分大小写;设置为gbk_bin区分大小写。
原因:
gbk_chinese_ci: 非二进制存储,不区分大小写
gbk_bin: 以二进制形式进行存储,区分大小写
2、如何修改排序规则
SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY `', column_name, '` ', DATA_TYPE, '(', CHARACTER_MAXIMUM_LENGTH, ') CHARACTER SET gbk COLLATE gbk_bin', (CASE WHEN IS_NULLABLE = 'NO' THEN ' NOT NULL' ELSE '' END), ';')
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'hs_his'
AND DATA_TYPE in ('varchar', 'char')
AND COLLATION_NAME = 'gbk_chinese_ci';