Pages

Wednesday, July 18, 2012

Next AUTO_INCREMENT number in mySQL

Here's a quick little tip if you are going to add a new item in a mySQL table and would like to know the next AUTO_INCREMENT value.

Simply query the mySQL-server for the next value in your table like this:

SELECT AUTO_INCREMENT FROM information_schema.TABLES 
WHERE TABLE_SCHEMA='<DB_NAME>' 
AND TABLE_NAME='<TABLE_NAME>

Replace <DB_NAME> and <TABLE_NAME> with the appropriate DB-schema and table name on your own mySQL server.

No comments:

Post a Comment