当前位置:网站首页>Mysql Duplicate entry ‘xxx‘ for key ‘xxx‘
Mysql Duplicate entry ‘xxx‘ for key ‘xxx‘
2022-06-30 00:27:00 【tang_ sy】
Preface : Recording errors , Pretty good , generous with your criticism
There's a picture, there's a truth
1、 problem :
Pictured parent_id and sku_id It's the only index , The query prompts that the unique index is duplicate !
2、 doubt :
Is it really repeated ?mysql Whether to set case sensitivity ?
3、 analysis :
As shown in the figure, user defined skuId,ZC05、zc05 Is different , The problem is mysql Is case insensitive , Lead to repetition !
4、 solve :
You need to set the case sensitivity
MySQL The character order names in follow the naming convention : Starts with the name of the character set corresponding to the character order ;
With _ci( Indicates case insensitive )、_cs( Indicates case sensitivity ) or _bin( Compare by code value ) ending .
5、 test :
situation 1、 Create table statement
CREATE TABLE `test_user` (
`user_id` int NOT NULL AUTO_INCREMENT,
`user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`password` int DEFAULT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`sex` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`invalid` int DEFAULT NULL,
`createTime` datetime DEFAULT NULL,
`updateTime` datetime DEFAULT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 
If you need to be case sensitive , Then the query is wrong
2、 Modify sort set , The query is normal
`user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs DEFAULT NULL,
3、 Modify sort set , It's normal
`user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
边栏推荐
- Is there any discount for securities account opening? Is it safe to open an account online?
- [PHP] PHP pressure test, error reporting: generally, each socket address (Protocol / network address / port) is only allowed to be used
- Rotating colored clover
- 传统微服务框架如何无缝过渡到服务网格 ASM
- Solr basic operations 12
- 请指教在线开户是什么意思?另外想问,现在在线开户安全么?
- 剑指 Offer II 037. 小行星碰撞
- MySQL basics 1
- Relevance - canonical correlation analysis
- TwinCAT 3 el7211 module controls Beifu servo
猜你喜欢

Sofaregistry source code | data synchronization module analysis

微信支付 APP端 第三弹 申请退款

Vulnhub target -moriartycorp
![[advanced C language] user defined type](/img/0d/50924ef21f07ca8188855c2b78d929.png)
[advanced C language] user defined type

剑指 Offer II 037. 小行星碰撞

博途V16 更改PLC的型号和固件版本

Summarize Flink runtime architecture in simple terms

vsftp 与 TFTP 与 samba 与 nfs 复习

mysql 死锁

简要的说一下:Fragment 间的通信方式?
随机推荐
Root cause of glideexception: failed decodepath{directbytebuffer- > gifdrawable- > drawable}
Vulnhub target -moriartycorp
中小企业签署ERP合同时,需要注意这几点
[daily question 1] traversal of binary tree
Activity invitation | the Apache Doris community essay and speech solicitation activity has begun!
炒股开户选择哪家券商公司比较好哪家平台更安全
01 backpack problem
固定资产管理系统多少钱,固定资产管理系统价格
间歇采样转发干扰
There is no web-based development for the reward platform. Which is suitable for native development or mixed development?
Findbugs modification summary
MySQL foundation 3
股票网上开户及开户流程怎样?还有,在线开户安全么?
Solr basic operation 8
HDCP Paring
[PHP] PHP pressure test, error reporting: generally, each socket address (Protocol / network address / port) is only allowed to be used
How to seamlessly transition from traditional microservice framework to service grid ASM
[advanced C language] dynamic memory management
Botu V16 changes the model and firmware version of PLC
[PHP] PHP variable memory release
