• 转载:mysql-Auto_increment值修改


    转载网址:http://libo93122.blog.163.com/blog/static/1221893820125282158745/

    查看db.table表的下一条记录auto_increment的值:
    show
    table status from db like 'table';


    如:
    mysql>
    show table status from mailbox like 'mailbox';         

    +---------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+---------------------+-------------------+----------+----------------+---------+
    |
    Name    | Engine | Version | Row_format | Rows | Avg_row_length | Data_length |
    Max_data_length | Index_length | Data_free |Auto_increment|
    Create_time         | Update_time         | Check_time          |
    Collation         | Checksum | Create_options | Comment |

    +---------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+---------------------+-------------------+----------+----------------+---------+
    |
    mailbox | MyISAM |      10 | Dynamic    | 1681 |            148 |      249688 |
    281474976710655 |       104448 |         0 |         15355|
    2012-03-13 11:19:10 | 2012-03-13 11:19:10 | 2012-03-13 11:19:10 |
    latin1_swedish_ci |     NULL |                |         |

    +---------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+---------------------+-------------------+----------+----------------+---------+
    1
    row in set (0.00 sec)


    Auto_increment:15355
    这个就是下一条记录会使用的自增ID;


    修改db.table表下一条记录使用的自增ID值为20000:
    alter
    table db.table auto_increment=20000;


    如:
    mysql> alter table
    mailbox.mailbox auto_increment=
    20000;          
    Query OK, 1681 rows affected
    (0.05 sec)

    这时再进行
    show table
    status from mailbox like 'mailbox'; 

    auto_increment已经变成20000;
    新插入的记录,自增字段就会从20000开始;

  • 相关阅读:
    vi 编辑器使用技巧
    sql____001
    PL/sql 启动时出现:NLS_LANG在客户端不能确定,字符集转变将造成不可预期的后果
    oracle数据库只查询前n条
    Linux下统计当前文件夹下的文件个数、目录个数
    oracle链接指定实例
    nmon的安装和使用
    jmeditor与CKEditor4x整合的BUG
    Word图片上传控件卸载教程-Xproer.WordPaster
    ScreenCapture手动卸载教程-Xproer.ScreenCapture
  • 原文地址:https://www.cnblogs.com/lraa/p/3700899.html
Copyright © 2020-2023  润新知