MySQL 自增ID 规格严格

http://hi.baidu.com/517898291/item/9cac18066030cac6905718e0

http://jiangshuiy.iteye.com/blog/751060

 

Sina 转载:

MySQL: Get next AUTO_INCREMENT value from/for table

Note to self: To get the next auto_increment value from a table run this query: SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = $dbName AND TABLE_NAME = $tblName. Don’t forget it (again).

给自己做笔记:从表中获取下一个自增值时只要运行以下sql语句即可:
AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = $dbName AND TABLE_NAME = $tblName;

例如:
SELECT auto_increment FROM information_schema.`TABLES` WHERE TABLE_SCHEMA='my_db_name' AND TABLE_NAME='my_table_name';

原文地址:http://www.bram.us/2008/07/30/mysql-get-next-auto_increment-value-fromfor-table/


另附一种PHP+mysql的方法:


$tablename         = "tablename";
$next_increment     = 0;
$qShowStatus         = "SHOW TABLE STATUS LIKE '$tablename'";
$qShowStatusResult     = mysql_query($qShowStatus) or die ( "Query failed: " . mysql_error() . "<br/>" . $qShowStatus );

$row = mysql_fetch_assoc($qShowStatusResult);
$next_increment = $row['Auto_increment'];

echo "next increment number: [$next_increment]";
?>

 
 
原文地址:https://www.cnblogs.com/diyunpeng/p/2988964.html