Get current AUTO_INCREMENT value for any table

bparise picture bparise · Apr 4, 2013 · Viewed 306k times · Source

How do I get the current AUTO_INCREMENT value for a table in MySQL?

Answer

methai picture methai · Apr 4, 2013

You can get all of the table data by using this query:

SHOW TABLE STATUS FROM `DatabaseName` WHERE `name` LIKE 'TableName' ;

You can get exactly this information by using this query:

SELECT `AUTO_INCREMENT`
FROM  INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'DatabaseName'
AND   TABLE_NAME   = 'TableName';