bparise bparise - 4 months ago 17
SQL Question

Get current AUTO_INCREMENT value for any table

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

Answer

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';
Comments