0

So, I have a database with 10 users in it in which each one of them has an id from 1 to 10. If I delete those 10 users from the database and then create a new user, the new user will start with the id of 11 and not 1. Any Ideas?

Zak
  • 6,976
  • 2
  • 26
  • 48
Diogo Cruz
  • 77
  • 1
  • 14
  • 1
    Possible duplicate of [Resetting the primary key to 1 after deleting all the data](https://stackoverflow.com/questions/6972275/resetting-the-primary-key-to-1-after-deleting-all-the-data) – Don't Panic May 28 '19 at 23:28
  • 1
    https://stackoverflow.com/questions/12651867/mysql-delete-all-rows-from-table-and-reset-id-to-zero – Don't Panic May 28 '19 at 23:30

1 Answers1

0

Instead of using the DELETE statment (which will keep your auto incrementing indexes, and start them from the last INSERTED index) use TRUNCATE

TRUNCATE TABLE database_name.table_name;

TRUNCATE REFERENCE

Any AUTO_INCREMENT value is reset to its start value. This is true even for MyISAM and InnoDB, which normally do not reuse sequence values.

Zak
  • 6,976
  • 2
  • 26
  • 48