当前位置:网站首页>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,
边栏推荐
- Vulnhub靶机-MoriartyCorp
- Web APIs 环境对象 丨黑马程序员
- MySQL:SQL概述及数据库系统介绍 | 黑马程序员
- 爬虫入门实战:斗鱼弹幕数据抓取,附送11节入门笔记
- Copy linked list with random pointer [space for time --hash record]
- [advanced C language] string and memory function (II)
- Label Troubleshooting: unable to open the marked image
- Introduction to reptiles: data capture of Betta barrage, with 11 introductory notes attached
- EB-5 immigration in the United States reappears to be positive, and the reauthorization policy of the regional center is suspended
- Inspiration collection · evaluation of creative writing software: flomo, obsidian memo, napkin, flowus
猜你喜欢

Review of vsftp, TFTP, samba and NFS

Statistical query of SQL Server database

js中的事件

云呐|固定资产系统管理的优势,固定资产管理系统有何特点
![[rust weekly library] Tokei - a utility for statistics of code lines and other information](/img/6c/4569cc0edaa01e4605c9c256193c31.png)
[rust weekly library] Tokei - a utility for statistics of code lines and other information

公司固定资产该哪个部门管理,一般公司固定资产怎么管理

Digital collection of cultural relics, opening a new way of cultural inheritance

Fine grained identification, classification, retrieval data set collation

由GlideException: Failed DecodePath{DirectByteBuffer->GifDrawable->Drawable}引起的刨根问底

Sword finger offer II 037 Asteroid collision
随机推荐
JS的初步语法
ThinkPad VMware installation virtual machine: this host supports Intel VT-x, but Intel VT-x is disabled (problem resolution)
[advanced C language] user defined type
Finding a job in 2022 is the "last lesson" for graduates
How to write controller layer code gracefully?
golang7_ TCP programming
Embedded development: Hardware in the loop testing
QT learning 02 GUI program example analysis
MySQL:SQL概述及数据库系统介绍 | 黑马程序员
旋转彩色三叶草
Introduction to reptiles: data capture of Betta barrage, with 11 introductory notes attached
Andorid source build/envsetup. SH details to know
Quick pow: how to quickly find power
蛇形矩阵(数组模拟方向, d代表转弯)
Color space conversion in video tonemapping (HDR to SDR) (bt2020 to bt709, YCbCr, YUV and RGB)
AI chief architect 9- huxiaoguang, propeller model library and industry application
gyctf_ 2020_ document
Solr基础操作12
MySQL multi table query
传统微服务框架如何无缝过渡到服务网格 ASM
