Wednesday, March 14, 2012

How to get next AUTO_INCREMENT value in mysql

there are two possibilities to access next auto_increment variable associated with a particular table in MySql

1) Using information schema

select auto_increment
from information_schema.tables
where table_schema = 'db_name'
 and table_name = 'table_name'

2) accessing status of database

SHOW TABLE STATUS  where name="table_name"

1st give only next auto increment value but second gives some additional information other than that.

hope this helps....cheers......


Related Posts with Thumbnails