当前位置:网站首页>关于 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
边栏推荐
- Refuse to work overtime, a productivity tool set developed by programmers
- Maximum area of solar panel od js
- PDF 拆分/合并
- Linux下redis7的安装,启动与停止
- f.grid_sample
- The effective square of the test (one question of the day 7/29)
- CV-Model [3]: MobileNet v2
- Introduction and use of Drools WorkBench
- The application of AI in the whole process of medical imaging equipment
- 基于FPGA的图像实时采集
猜你喜欢

multiplayer-hlap 包有问题,无法升级的解决方案

934. 最短的桥

mysql view

Introduction and use of Drools WorkBench

Basic introduction to ShardingJDBC

MPPT solar charge controller data collection - through the gateway acquisition capacity battery SOC battery voltage, wi-fi

What does a software test report contain?

直播预告 | KDD2022博士论文奖冠亚军对话

19.支持向量机-优化目标和大间距直观理解

【Bank Series Phase 1】People's Bank of China
随机推荐
Static routing + PAT + static NAT (explanation + experiment)
12 pictures take you to fully understand service current limit, circuit breaker, downgrade, and avalanche
Linux下redis7的安装,启动与停止
BAT卖不动「医疗云」:医院逃离、山头林立、行有行规
VSCode Plugin: Nested Comments
Installation, start and stop of redis7 under Linux
全流程调度——MySQL与Sqoop
Project development software directory structure specification
MPPT太阳能充放电控制器数据采集-通过网关采集电池电压容量电量SOC,wifi传输
静态路由解析(最长掩码匹配原则+主备路由)
What does a software test report contain?
Maximum monthly salary of 20K?The average salary is nearly 10,000... What is the experience of working in a Huawei subsidiary?
General introduction to the Unity interface
项目开发软件目录结构规范
mysql 视图
The comprehensive result of the case statement, do you know it?[Verilog Advanced Tutorial]
After reading "MySQL Database Advanced Practice" (SQL Xiao Xuzhu)
There is a problem with the multiplayer-hlap package and the solution cannot be upgraded
Crypto Life, a day in the life of a Web3 project partner
PDF 拆分/合并