当前位置:网站首页>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
边栏推荐
- 「 每日一练,快乐水题 」1331. 数组序号转换
- Bubble sort, selection sort, insertion sort, binary search directly
- SQL Interview Questions (Key Points)
- C语言从入门到如土——数据的存储
- Observer pattern
- [C language] General method of expression evaluation
- Redis implements distributed locks
- With 7 years of experience, how can functional test engineers improve their abilities step by step?
- 安全20220718
- 顺序表的实现
猜你喜欢

The application and practice of mid-to-platform brand advertising platform

Mysql 45 study notes (twenty-five) MYSQL guarantees high availability

Just debuted "Fight to Fame", safety and comfort are not lost

Mysql 45 study notes (twenty-four) MYSQL master-slave consistency

《DeepJIT: An End-To-End Deep Learning Framework for Just-In-Time Defect Prediction》论文笔记

A brief introduction to the showDatePicker method of the basic components of Flutter

IIR filter and FIR filter

The BP neural network

(四)递归、可变参数、访问修饰符、理解 main 方法、代码块

Key Technologies of Interface Testing
随机推荐
一份高质量的测试用例如何养成?
Automation strategies for legacy systems
els block to the right
type_traits metaprogramming library learning
els 方块向左移动条件判断
Mysql 45 study notes (23) How does MYSQL ensure that data is not lost
浅识Flutter 基本组件之CheckBox组件
WebSocket Session is null
errno错误码及含义(中文)
组件传值 provide/inject
beforeDestroy与destroyed的使用
安全20220715
The els block moves the boundary to the right, and accelerates downward.
(八)Math 类、Arrays 类、System类、Biglnteger 和 BigDecimal 类、日期类
els 方块向右移动边界判断、向下加速
2022 Nioke Multi-School League Game 4 Solution
els block to the left to move the conditional judgment
Addition and Subtraction of Scores in LeetCode Medium Questions
$attrs/$listeners
web容器及IIS --- 中间件渗透方法1