Get current MySQL auto increment value of a certain TABLE.

May 22, 2016 | 239 views | Comments

Sometimes, the highest id is not always the "auto increment" value. If a record with the highest id was deleted, that assumption will be incorrect.

The MySQL code below will return the correct auto increment value from a given DATABASE and TABLE.

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

Related Tutorials


Must Read