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
Element UI implements multiple tables scrolling a...
Table of contents 1. Create a redis docker base i...
When you get a new Linux server, you generally ha...
1. Find mysqldump.exe in the MySQL installation p...
Preface: With the continuous development of Inter...
Three ways to set borders in HTML border-width: 1...
Table of contents text 1. Prepare the machine 2. ...
Table of contents 1. The origin of fork 2. Early ...
1. Design source code Copy code The code is as fol...
Preface In WEB development, we often involve cros...
The core is mysqldump and Runtime The operation i...
In the previous article, I introduced how to solv...
Table of contents 1 Indicators in stress testing ...
Introduction to sudo authority delegation su swit...
Query the total size of all databases Here’s how:...