mysql self-increment restarts on its own

2

I have the same problem described here at this link: link

The guidance given here was to do this: link

But I did not quite understand, could anyone explain the solution given in this second link?

    
asked by anonymous 26.11.2015 / 11:07

2 answers

1

There it explains that TRUNCATE TABLE resets the AutoIncrement fields of the table, and that DELET FROM does not reset the fields, even if you delete the row that contains the highest value AutoIncrement will not be reset!

Review your codes you may be using Truncate!

    
26.11.2015 / 11:16
1

Comparing TRUNCATE TABLE:

  

Any AUTO_INCREMENT value is reset to its initial value. This holds true for both MyISAM and InnoDB, which does not normally occur with string values. DELETE FROM TABLE ...

     

If you delete the record that contains the maximum ID "MAX (ID)", which is an AUTO_INCREMENT column, the value will no longer be updated for both MyISAM and InnoDB. Now, if you delete all records from the table, with DELETE FROM TABLE (without using the WHERE clause) with automatic commit mode, the sequence will be restarted on all InnoDB storage engines, except for MyISAM tables. for this behavior for InnoDB tables, as discussed in the Section 13.3.5.3 , "Maintenance of AUTO_INCREMENT for InnoDB".

     

For MyISAM tables, you can define a new secondary AUTO_INCREMENT column with a multiple-column type switch. In this way, you can reuse the deleted values from the beginning of the sequence. See Section 3.6.9 , "Using AUTO_INCREMENT."

    
26.11.2015 / 13:24