Besides using MySQL's DESCRIBE
syntax and parsing the Type
column, is there any way to programmatically determine what's the largest integer that can be stored in a given INT
column and its varieties? (e.g. TINYINT
, MEDIUMINT
, etc.) I'd simply store a hard-coded table, except that my columns use custom lengths like TINYINT(2)
and MEDIUMINT(5)
.
I ask because I'm thinking of writing a cron job to warn me when my various auto-incrementing integer-based ID columns approach their maximum values, so I can reduce the risk of integer overruns.
Edit
I see this was kind of a dumb question. As was pointed out to me, the custom lengths don't affect the maximum integer values that those columns can store. So if I wanted to write the script, I can hard-code the maximum integer sizes given in the MySQL manual. As to whether this script is the best way to handle things, that's debatable.