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
The effect is as follows: Example 1 Example 2: Ta...
Currently, most CPUs support floating-point units...
Docker runs multiple Springboot First: Port mappi...
<p><b>This is bold font</b></...
The effect is as follows: analyze 1. Here you can...
Table of contents Overview What are Generics Buil...
MySQL replication table detailed explanation If w...
Table of contents 1. Installation 2. Use Echarts ...
Preface We all know that MySQL uses server-id to ...
The data type of MySQL is datetime. The data stor...
Assuming you are a linuxer , we don't want to...
Similar to the code hosting service provided by G...
Collapsed headers are a great solution for displa...
The commonly used escape characters in HTML are s...
cursor A cursor is a method used to view or proce...