当前位置:网站首页>关于 mysql8.0数据库中主键位id,使用replace插入id为0时,实际id插入后自增导致数据重复插入 的解决方法
关于 mysql8.0数据库中主键位id,使用replace插入id为0时,实际id插入后自增导致数据重复插入 的解决方法
2022-07-31 02:21:00 【长沙红胖子Qt】
若该文为原创文章,转载请注明原文出处
本文章博客地址:https://hpzwl.blog.csdn.net/article/details/126074729
红胖子(红模仿)的博文大全:开发技术集合(包含Qt实用技术、树莓派、三维、OpenCV、OpenGL、ffmpeg、OSG、单片机、软硬结合等等)持续更新中…
数据库相关开发
需求
配置文件存入有时候数据库没有初始化一条数据,所有想使用有数据就更新,没数据则插入的方式。
问题
在实际调试过程中,发现id为0时,每次replace表id为0的记录,都会使id自增,如下图:
表数据结构定义和操作
解决方式一:修改id值,id值不能为0
将存入的id值改为1,验证不能为0,为0则会自动自增添加新的一条数据。
解决方法二:修改表结构,id改为不自增
若该文为原创文章,转载请注明原文出处
本文章博客地址:https://hpzwl.blog.csdn.net/article/details/126074729
边栏推荐
- "Cloud native's master, master and vulgar skills" - 2022 National New College Entrance Examination Volume I Composition
- Go 项目实战-获取多级分类下的全部商品
- VSCode Plugin: Nested Comments
- 系统需求多变如何设计
- The comprehensive result of the case statement, do you know it?[Verilog Advanced Tutorial]
- Tower of Hanoi problem
- Draw Your Cards
- Maximum area of solar panel od js
- 基于opencv实现人脸检测
- 静态路由解析(最长掩码匹配原则+主备路由)
猜你喜欢
【Bank Series Phase 1】People's Bank of China
There is a problem with the multiplayer-hlap package and the solution cannot be upgraded
静态路由解析(最长掩码匹配原则+主备路由)
pycharm cannot run after renaming (error: can't open file...No such file or directory)
19. Support Vector Machines - Intuitive Understanding of Optimization Objectives and Large Spacing
Mathematics to solve the problem - circular linked list
What does a software test report contain?
用户交互+格式化输出
二层广播风暴(产生原因+判断+解决)
221. Largest Square
随机推荐
mmdetection trains a model related command
最大路径和
AI在医疗影像设备全流程应用
Drools WorkBench的简介与使用
力扣刷题之爬楼梯(7/30)
Mathematical Ideas in AI
BAT卖不动「医疗云」:医院逃离、山头林立、行有行规
Arbitrum Interview | L2 Summer, what does the standout Arbitrum bring to developers?
19. Support Vector Machines - Intuitive Understanding of Optimization Objectives and Large Spacing
Manchester City confuses fans with smart scarf that detects emotions
静态路由解析(最长掩码匹配原则+主备路由)
汉源高科8路HDMI综合多业务高清视频光端机8路HDMI视频+8路双向音频+8路485数据+8路E1+32路电话+4路千兆物理隔离网络
Layer 2 broadcast storm (cause + judgment + solution)
f.grid_sample
Inter-vlan routing + static routing + NAT (PAT + static NAT) comprehensive experiment
"Cloud native's master, master and vulgar skills" - 2022 National New College Entrance Examination Volume I Composition
My first understanding of MySql, and the basic syntax of DDL and DML and DQL in sql statements
There is a problem with the multiplayer-hlap package and the solution cannot be upgraded
The principle of complete replication of virtual machines (cloud computing)
String为什么不可变?