proxy代理   soft软件   IT 业界特快   norton 诺顿病毒库   代理列表   search FTP搜索   whois IP地理位置   blog 追求完美  
money理财   life生活   RSS聚合门户   firefox WEB浏览器   免费域名   typeset 假古文   AntiVirus 反病毒   ipcn 站点导航  

« sitemap_gen 生成 Google Sitemaps 需要的网站地图 | Main | tar zxfk filename.tar.gz -k,--keep-old-files 不覆盖已存在文件 »

September 21, 2005

用 myisamchk 调整 mysql 的 auto_increment 自增列的 id

版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明。
https://windtear.net/archives/2005/09/21/000776.html http://windtear.net/archives/2005/09/21/000776.html

问题:
mysql 的 auto_increment 列中的数据记录如果被删了
后面的值将不复用老的

文档:
http://dev.mysql.com/doc/mysql/en/example-auto-increment.html

解决:
myisamchk 可以解决这个问题

cd /var/lib/mysql/yourdb
myisamchk -A yourtbl

  -A, --set-auto-increment[=value]
                      Force auto_increment to start at this or higher value
                      If no value is given, then sets the next auto_increment
                      value to the highest used value for the auto key + 1.

然后下一次插入数据 auto_increment id 就变成当前最大值加1了
想得到连续 id 的愿望就实现了
本blog WWW

Posted by windtear at September 21, 2005 7:20 PM

本站使用中的任何问题,请与 windtear @ windtear.net 联系
Copyright© 1999-2024 Windtear. All rights reserved.