How to reset the initial value of the auto-increment column in the MySQL table 1. Problem Statement In MySQL database design, an auto-increment numeric column is usually designed to be used as a primary key that is not related to the business. After frequent deletion or clearing operations occur in the database, its auto-increment value will still increase automatically. What should you do if you need to start over? 2. Solution a. alter table delete from table_name; ALTER TABLE table_name AUTO_INCREMENT = 1; If there is a lot of data in the database table, the deletion operation will take a long time, so this problem needs attention. b. truncate truncate table_name Simple and fast, clear data directly. 3. delete vs tuncate The main differences are as follows:
Thank you for reading, I hope it can help you, thank you for your support of this site! You may also be interested in:
|
<<: Example of implementing todo application with Vue
>>: Solution for installing opencv 3.2.0 in Ubuntu 18.04
Type yum install mysql-server Press Y to continue...
What is Let’s first look at the concept of Docker...
Preface We all know that in Linux, "everythi...
Solution to MySql service disappearance for unkno...
This article example shares the specific code of ...
Written in front Environment: MySQL 5.7+, MySQL d...
What is it? Spring Boot is a sub-project of the S...
1. Commonjs Commonjs is a custom module in nodejs...
As Web developers, although we are not profession...
Generally speaking, the background color of a web ...
Table of contents Introduction to frm files and i...
OBS studio is cool, but JavaScript is cooler. Now...
Today, this post lists some great examples of circ...
Preface Most of our MySQL online environments use...
System: Ubuntu 16.04LTS 1\Download mysql-5.7.18-l...