Skip to content

Instantly share code, notes, and snippets.

@dannyfallon
Created September 1, 2017 13:34
Show Gist options
  • Save dannyfallon/974737d887f3270dc2c237a2188c7014 to your computer and use it in GitHub Desktop.
Save dannyfallon/974737d887f3270dc2c237a2188c7014 to your computer and use it in GitHub Desktop.
Determining what tables with an auto incrementing primary key are coming close to the max of the int datatype (80%)
SELECT t.TABLE_NAME, `AUTO_INCREMENT`
FROM information_schema.TABLES AS t
JOIN information_schema.COLUMNS AS c ON (
c.COLUMN_NAME = 'id' AND
c.TABLE_SCHEMA = t.TABLE_SCHEMA AND
c.TABLE_NAME = t.TABLE_NAME AND
c.`DATA_TYPE` = 'int'
)
WHERE AUTO_INCREMENT > 1717986918;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment