mysql-Auto_increment值修改
上一篇 /
下一篇 2012-03-13 12:13:31
/ 个人分类:Mysql
测试时,为了模拟一些特殊情况,需要
修改某张表的下一条记录的Auto_increment值
可通过如下方法进行处理:
查看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开始;
相关阅读:
- 在服务器上安装、使用MySQL的注意事项 (xin_晴, 2012-2-06)
- 超越MySQL:三个流行MySQL分支的对比 (xin_晴, 2012-2-07)
- mysql-show slave status 参数详解-zt (fairylly, 2012-2-07)
- 如何解决MySQL数据库主从服务器之间数据有差距问题 (xin_晴, 2012-2-09)
- MySQL数据切分的相关概念和原理详解 (xin_晴, 2012-2-14)
- MySQL内存表的特性与使用介绍 (xin_晴, 2012-2-24)
- MySQL的四种不同查询的分析 (xin_晴, 2012-3-01)
- MySQL源码学习:MDL字典锁 (xin_晴, 2012-3-02)
- MySQL数据库创建线程的相关操作详解 (xin_晴, 2012-3-09)
- PHP与MySQL数据库中排序的对比及使用条件详解 (xin_晴, 2012-3-12)
收藏
举报
TAG:
auto
修改
increment
MySQL
mysql