当前位置:网站首页>Mysql database field query case sensitive setting
Mysql database field query case sensitive setting
2022-06-26 09:38:00 【A constant stream of cars】
Use navicat Create database , Character set selection utf8, If the sorting rule is not selected , Create successful session , Check the database properties and find that the sorting rules are set by default, as shown in the following figure :

Once created , Create table testcase, adopt show CREATE TABLE testcase View the table creation statement , The following are not case sensitive [ Sort rule :utf8_genera_ci Case insensitive ]
CREATE TABLE `testcase` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
INSERT INTO `testcase` ( `name`, `time`) VALUES ('WX0001', '2022-06-22');
INSERT INTO `testcase` ( `name`, `time`) VALUES ('wx0001', '2022-06-22');
Insert the statement above , Because it's not case sensitive , With a unique index field name Failed to insert the second record of

Modify table character set
ALTER TABLE testcase CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
utf8_bin Store every character in the string in binary data , Case sensitive
How many rows does the database currently have , How many lines will be affected
CREATE TABLE `testcase` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin
After modification , Insert the lowercase field value that just failed again
INSERT INTO `testcase` ( `name`, `time`) VALUES ('wx0001', '2022-06-22');
You can see that the insertion was successful , Case sensitivity is set successfully

边栏推荐
- MapReduce&Yarn理论
- 【pulsar学习】pulsar架构原理
- jz2440---使用uboot烧录程序
- 深度学习(初识tensorflow2.版本)之三好学生成绩问题(1)
- 安装 新版本cmake & swig & tinyspline
- SQL modification of table structure
- I am in Zhongshan. Where can I open an account? Is online account opening safe?
- Differences between VI and vim and common commands
- Summary of common commands of vim
- pcl install
猜你喜欢

《一周搞定模电》—负反馈

Classified catalogue of high quality sci-tech periodicals in the field of computing

《一周搞定模电》-光耦等元器件

Construction practice of bank intelligent analysis and decision-making platform
![Pycharm [debug] process stuck](/img/8c/c32cbdfcb106b34fccbbc071a13822.jpg)
Pycharm [debug] process stuck

我的创作纪念日

工企专利匹配数据(数十万数据量)1998-2014年

Badge series 8: generate a personalized Badge

Master data management of scientific research institutes? Suppliers or customers? I am a correspondent

How does flutter transfer parameters to the next page when switching pages?
随机推荐
[pulsar learning] pulsar Architecture Principle
Differences between VI and vim and common commands
【CVPR 2021】Unsupervised Pre-training for Person Re-identification(UPT)
There is a strong demand for enterprise level data integration services. How to find a breakthrough for optimization?
【pulsar学习】pulsar架构原理
Function function of gather()
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.npm ER
Champions League data set (Messi doesn't cry - leaving Barcelona may reach another peak)
《一周搞定模电》—负反馈
"One week's data collection" -- combinational logic circuit
挖财打新债安全吗
logback
我的创作纪念日
Learning to Generalize Unseen Domains via Memory-based Multi-Source Meta-Learning for Person Re-ID
Origin of QPM
【Open5GS】Open5GS安装配置
异常记录-23
How to solve the problem that NVIDIA model cannot be viewed by inputting NVIDIA SMI and quickly view NVIDIA model information of computer graphics card
2021-11-12 vrep视觉传感器配置
Cancellation and unbinding of qiniu cloud account