How can I reset the AUTO_INCREMENT
of a field? I want it to start counting from 1
again.
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- sqlyog export query result as csv
You can simply truncate the table to reset the sequence
You can also use the syntax
TRUNCATE
table like this :TRUNCATE TABLE table_name
BEWARE!!
TRUNCATE TABLE your_table
will delete everything in youryour_table
!!Best way is remove the field with AI and add it again with AI, works for all tables
I suggest you to go to Query Browser and do the following:
Auto_increment should reset to one once you enter new row int the table.
I don't know what will happen if you try to add a row where an auto_increment field value already exist.
Hope this help!
As of MySQL 5.6 the approach below works faster due to online DDL (note
algorithm=inplace
):alter table tablename auto_increment=1, algorithm=inplace;