search

Home  >  Q&A  >  body text

MYSQL Workbench - Index after deletion (Java)

<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>
P粉729518806P粉729518806438 days ago528

reply all(1)I'll reply

  • P粉343141633

    P粉3431416332023-09-06 09:18:20

    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.

    reply
    0
  • Cancelreply