MYSQL Workbench - Index after deletion (Java)
P粉729518806
2023-09-05 10:34:42
<p>I have a problem with MYSQL Workbench. Let's say I have this table and user "x" has an index of 8. Let's say I delete this user so now I only have 7 users. If I create a new user using the Java console, the new user will be created with ID 9 because it is auto-incremented. Is there a way to tell Workbench to start from the last number? In this specific case, create the new user starting from 8 instead of 9? </p>
<p>I tried checking everywhere on the web but only found some queries to recreate the table but that's not what I want because I have some foreign keys linked to the table so I can't just drop the table and recreate Create another one. </p>
I'm not familiar with MYSQL Workbench, but I think you might be able to alter the table and change the value of AUTO_INCRMENT.
Here is a link that discusses it in more detail and even has an example: https://www.w3schools.com/mysql/mysql_autoincrement.asp
Hope this helps.