zoukankan      html  css  js  c++  java
  • 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]";
    ?>

     
     
  • 相关阅读:
    TODO 模板实践
    C++类继承方式及实践
    【转】C++友元
    C++面向对象实践
    数组指针实践
    引用&指针交换函数实践
    左值引用&右值引用实践【TODO】
    const变量的修改实践
    【转】c语言动态与静态分配
    【转】数组指针&指针数组
  • 原文地址:https://www.cnblogs.com/diyunpeng/p/2988964.html
Copyright © 2011-2022 走看看