当前位置:网站首页>Regarding the primary key id in the mysql8.0 database, when the id is inserted using replace to be 0, the actual id is automatically incremented after insertion, resulting in the solution to the repea
Regarding the primary key id in the mysql8.0 database, when the id is inserted using replace to be 0, the actual id is automatically incremented after insertion, resulting in the solution to the repea
2022-07-31 03:37:00 【Changsha Red Fatty Qt】
If this article is an original article, please indicate the source of the original text for reprinting
The blog address of this article: https://hpzwl.blog.csdn.net/article/details/126074729
Database related development
Requirements
The configuration file is stored. Sometimes the database does not initialize a piece of data. All you want to use is the method of updating if there is data, and inserting if there is no data.
Question
In the actual debugging process, when it is found that the id is 0, each time the record with the id of 0 is replaced, the id will be incremented automatically, as shown below:

Table data structure definition and manipulation




Solution 1: Modify the id value, the id value cannot be 0
Change the stored id value to 1. The verification cannot be 0. If it is 0, it will automatically add a new piece of data.
Solution 2: Modify the table structure and change the id to not increase automatically


If this article is an original article, please indicate the source of the original text for reprinting
The blog address of this article: https://hpzwl.blog.csdn.net/article/details/126074729
边栏推荐
- Redis uses LIST to cache the latest comments
- Can‘t load /home/Iot/.rnd into RNG
- els block to the right
- 7年经验,功能测试工程师该如何一步步提升自己的能力呢?
- errno错误码及含义(中文)
- SQL Interview Questions (Key Points)
- A brief introduction to the CheckboxListTile component of the basic components of Flutter
- web容器及IIS --- 中间件渗透方法1
- How Zotero removes auto-generated tags
- IDEA comment report red solution
猜你喜欢

IDEA常用快捷键与插件

Just debuted "Fight to Fame", safety and comfort are not lost
![[Compilation principle] Design principle and implementation of recursive descent parsing](/img/51/cd054a8246dc108520d6ff9ea26c60.png)
[Compilation principle] Design principle and implementation of recursive descent parsing

What is a system?
![[Swift] Customize the shortcut that pops up by clicking the APP icon](/img/d4/84b237995fc3d3700916eb57f6670d.png)
[Swift] Customize the shortcut that pops up by clicking the APP icon

Daily practice of LeetCode - palindrome structure of OR36 linked list

postgresql 15源码浅析(5)—— pg_control

端口排查步骤-7680端口分析-Dosvc服务
![[Paper reading] Mastering the game of Go with deep neural networks and tree search](/img/4f/899da202e13bd561bbfdbaeebe4d2e.jpg)
[Paper reading] Mastering the game of Go with deep neural networks and tree search

Getting Started with CefSharp - winform
随机推荐
IDEA 注释报红解决
PMP WeChat group daily exercises
[C language] Three-pointed chess (classic solution + list diagram)
The BP neural network
web容器及IIS --- 中间件渗透方法1
"DeepJIT: An End-To-End Deep Learning Framework for Just-In-Time Defect Prediction" paper notes
How to develop a high-quality test case?
[C language] General method for finding the sum of the greatest common factor and the least common multiple of two integers m and n, the classical solution
Analysis summary - self-use
5. How does the SAP ABAP OData service support the $filter operation
Safety 20220709
Getting Started with CefSharp - winform
大小端模式
Difference between unallocated blocks and unused blocks in database files
IDEA common shortcut keys and plug-ins
想从手工测试转岗自动化测试,需要学习哪些技能?
2022 Nioke Multi-School League Game 4 Solution
endian mode
The els block moves the boundary to the right, and accelerates downward.
No qualifying bean of type 问题