当前位置:网站首页>Mysql Duplicate entry ‘xxx‘ for key ‘xxx‘
Mysql Duplicate entry ‘xxx‘ for key ‘xxx‘
2022-06-30 00:21:00 【tang_sy】
前言:记录错误,才疏学浅,不吝赐教
有图有真相
1、问题:
如图parent_id和sku_id 是唯一索引,报问提示唯一索引重复!
2、疑问:
是否真的重复?mysql是否设置区分大小写?
3、分析:
如图用户自定义skuId,ZC05、zc05是不同的,出问题是mysql是不区分大小写,导致重复!
4、解决:
需要设置区分大小
MySQL中的字符序名称遵从命名惯例:以字符序对应的字符集名称开头;
以_ci(表示大小写不敏感)、_cs(表示大小写敏感)或_bin(表示按编码值比较)结尾。
5、测试:
情况1、建表语句
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; 
如果需要区分大小写,那么查询就是错误的
2、修改排序集,查询正常
`user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs DEFAULT NULL,
3、修改排序集,也正常
`user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
边栏推荐
- 项目一:部署 LAMP ecshop电商平台
- HTAP x cloud native: tidb accelerates the release of data value and realizes data agility
- Stream collectors usage
- 【UITableView】坑一:tableView:heightForHeaderInSection:方法不执行
- Introduction to reptiles: data capture of Betta barrage, with 11 introductory notes attached
- 请指教在线开户是什么意思?另外想问,现在在线开户安全么?
- Summary of DOM knowledge points
- Solr基础操作13
- Review of vsftp, TFTP, samba and NFS
- Code analysis platform sonarqube actual combat
猜你喜欢

Automatic integration: yescomusa, an overseas cross-border e-commerce, cooperates with cloud expansion to realize one-stop Automation Service

Golang6 reflection
![多数元素II[求众数类之摩尔投票法]](/img/8f/5925f97c0f5f8c50c19a9ef6d7723c.png)
多数元素II[求众数类之摩尔投票法]

关联性——典型相关分析

Andorid source build/envsetup.sh 该知道的细节

MySQL multi table query

vsftp 与 TFTP 与 samba 与 nfs 复习

Five key elements of the data center

项目一:部署 LAMP ecshop电商平台

Quick Pow: 如何快速求幂
随机推荐
Solr basic operations 9
Statistical query of SQL Server database
There is no web-based development for the reward platform. Which is suitable for native development or mixed development?
视频ToneMapping(HDR转SDR)中的颜色空间转换问题(BT2020转BT709,YCbCr、YUV和RGB)
[advanced C language] string and memory function (I)
Can't recognize the original appearance
QT learning 01 GUI program principle analysis
MySQL multi table query
JS draw polar color gradient
AI chief architect 9- huxiaoguang, propeller model library and industry application
Solr基础操作12
ThinkPad VMware installation virtual machine: this host supports Intel VT-x, but Intel VT-x is disabled (problem resolution)
[review and Book delivery] 6 interesting R language projects for beginners
QT learning 07 coordinate system in QT
克隆无向图[bfs访问每条边而不止节点]
C MDI open subform to remove automatically generated menu bar
Automatic integration: yescomusa, an overseas cross-border e-commerce, cooperates with cloud expansion to realize one-stop Automation Service
Three postures of anti CSRF blasting
QT learning 05 introduction to QT creator project
公司固定资产该哪个部门管理,一般公司固定资产怎么管理
