OK, Y’all. If you have been a DBA long enough you have run into situations where you’ve had to import DDL from another database instance and forgotten to remove AUTO_INCREMENT on a table definition. Sometimes this means your auto_increment is way up in the millions and you have 10 rows in the table. People worried about ID depletion on an integer column will do a “facepalm”.
Making matters worse, having perhaps done this on more than one table, sometimes it’s a real pain to detect and fix the issue of auto_increments being much higher than you want them to be across a big number of tables. Sometimes the pain is so great that you might want to simply repeat your data importation.
This quick and dirty “southern fried” script will help you report and rectify that. It detects your auto_increment columns and checks them by querying “ORDER BY <auto_increment_column> desc limit 1” I coded it in bash to be the “least objectionable”, so maybe some readers will actually use it.
So far the script is “lightly tested” so use at your own risk.