auto_increment command for Id does not work after erasing data and rewriting it

Asked

Viewed 250 times

0

When I create a table with the column "Id int not null auto_increment" and enter values in the table, after deleting the values and reinserting them, the Id does not part of 1, and sometimes with a random order. And besides appearing 8 Row(s) affected Records, it also appears 8 Duplicates, even though the values have already been deleted from the table. Could someone help me restore my 1 id after restarting the table?

Script:

  • I understood that I can give: alter table games auto_increment=1, but how can I do this if I delete an id in the middle of the others to organize them again?

  • The id never reorganizes, if you want to clean the table completely, including the auto_increment, use the command TRUNCATE TABLE nome_da_sua_tabela;. Remember that this command clears all table data.

  • Avoid posting code images. Give preference to post the code itself, so the person can test and find the best solution. [mcve]

  • Okay, thank you very much.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.