码迷,mamicode.com
首页 > 数据库 > 详细

mysql的AUTO_INCREMENT失效问题

时间:2014-11-14 15:33:10      阅读:383      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   sp   for   on   问题   log   

创建表设置的AUTO_INCREMENT属性在执行truncate操作后,自增序列会自动被置为0

 

http://dev.mysql.com/doc/refman/5.0/en/truncate-table.html

For an InnoDB table before version 5.0.3, InnoDB processes TRUNCATE TABLE by deleting rows one by one. As of MySQL
5.0.3, row by row deletion is used only if there are any FOREIGN KEY constraints that reference the table. If there
are no FOREIGN KEY constraints, InnoDB performs fast truncation by dropping the original
table and creating an empty one with the same definition, which is much faster
than deleting rows one by one. (When fast truncation is used, it resets any
AUTO_INCREMENT counter to zero. From MySQL 5.0.13 on,
the AUTO_INCREMENT counter is reset to zero by TRUNCATE TABLE,
regardless of whether there is a foreign key constraint.)

mysql的AUTO_INCREMENT失效问题

标签:blog   http   io   ar   sp   for   on   问题   log   

原文地址:http://www.cnblogs.com/huangjianan/p/4097316.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!