Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I view the auto_increment value for a table

The only way I know is show create table MyTable

like image 648
700 Software Avatar asked Oct 23 '10 13:10

700 Software


3 Answers

SHOW TABLE STATUS LIKE "tablename";

the auto_increment column will show the count.

like image 102
Pekka Avatar answered Oct 27 '22 00:10

Pekka


SELECT `AUTO_INCREMENT`
  FROM `information_schema`.`TABLES`
 WHERE `TABLE_SCHEMA` = SCHEMA()
   AND `TABLE_NAME` = 'tbl_name';
like image 23
dev-null-dweller Avatar answered Oct 27 '22 00:10

dev-null-dweller


You can use LAST_INSERTED_ID function.

like image 36
Pablo Santa Cruz Avatar answered Oct 27 '22 00:10

Pablo Santa Cruz