<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" > <channel><title>Comments on: MySQL: Reset Auto Increament Number</title> <atom:link href="http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/feed/" rel="self" type="application/rss+xml" /><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/</link> <description>Tech, Web, How to, Reviews, Tips, Downloads, and Make Money Online</description> <lastBuildDate>Sat, 21 Nov 2009 13:44:35 +0800</lastBuildDate> <generator>http://wordpress.org/?v=2.8.5</generator> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>By: anhtrue</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-328905</link> <dc:creator>anhtrue</dc:creator> <pubDate>Sun, 26 Jul 2009 17:53:26 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-328905</guid> <description>thanks a lot! it is very helpful. I have the same problem with my database. </description> <content:encoded><![CDATA[<p>thanks a lot! it is very helpful. I have the same problem with my database.</p> ]]></content:encoded> </item> <item><title>By: sandeep</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-328752</link> <dc:creator>sandeep</dc:creator> <pubDate>Fri, 24 Jul 2009 14:45:10 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-328752</guid> <description>SET @var_name = 0; UPDATE gmid SET ID = (@var_name := @var_name +1); Wow Bach You Are God Man i have a huge problem 100000 records and in first 500 i had a huge gap like after id30 next record starts from id 167 i run that and voilla my ids are starts again from 1 and all sorted man u make my day thank you genius !! </description> <content:encoded><![CDATA[<p>SET @var_name = 0;<br /> UPDATE gmid SET ID = (@var_name := @var_name +1);</p><p>Wow Bach You Are God Man i have a huge problem 100000 records and in first 500 i had a huge gap like after id30 next record starts from id 167 i run that and voilla my ids are starts again from 1 and all sorted man u make my day thank you genius !!</p> ]]></content:encoded> </item> <item><title>By: pablo</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-256558</link> <dc:creator>pablo</dc:creator> <pubDate>Sat, 10 Feb 2007 01:16:04 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-256558</guid> <description>&quot;OMW&quot; does that mean &quot;Oh my Woz&quot;? because Wozzie&#039;s kinda like a god... to some.Seriously though, ALTER TABLE Tablename AUTO_INCREMENT = 6; Genius!Thanks so much.</description> <content:encoded><![CDATA[<p>&#8220;OMW&#8221; does that mean &#8220;Oh my Woz&#8221;? because Wozzie&#8217;s kinda like a god&#8230; to some.</p><p>Seriously though,<br /> ALTER TABLE Tablename AUTO_INCREMENT = 6;<br /> Genius!</p><p>Thanks so much.</p> ]]></content:encoded> </item> <item><title>By: william</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-243208</link> <dc:creator>william</dc:creator> <pubDate>Fri, 26 Jan 2007 11:10:42 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-243208</guid> <description>OMW... you just saved me having to re-enter like 400 records this afternoon. you&#039;re the best Bach</description> <content:encoded><![CDATA[<p>OMW&#8230; you just saved me having to re-enter like 400 records this afternoon. you&#8217;re the best Bach</p> ]]></content:encoded> </item> <item><title>By: Bach</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-240135</link> <dc:creator>Bach</dc:creator> <pubDate>Tue, 23 Jan 2007 21:46:53 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-240135</guid> <description>To Eugene:To re number the ID instead you can do this magic trick:SET @var_name = 0; UPDATE Tablename SET ID = (@var_name := @var_name +1);You can change @var_name to start from 80, and your ID will be: 81, 82,83, ...then combine it withALTER TABLE Tablename AUTO_INCREMENT = 6;So the next auto_increment will be 6 , and all your ID is 1,2,3,4,5. Hope this helps.Thanks.</description> <content:encoded><![CDATA[<p>To Eugene:</p><p>To re number the ID instead you can do this magic trick:</p><p>SET @var_name = 0;<br /> UPDATE Tablename SET ID = (@var_name := @var_name +1);</p><p>You can change @var_name to start from 80, and your ID will be:<br /> 81, 82,83, &#8230;</p><p>then combine it with</p><p>ALTER TABLE Tablename AUTO_INCREMENT = 6;</p><p>So the next auto_increment will be 6 , and all your ID is 1,2,3,4,5.<br /> Hope this helps.</p><p>Thanks.</p> ]]></content:encoded> </item> <item><title>By: T2_T2</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-27234</link> <dc:creator>T2_T2</dc:creator> <pubDate>Wed, 24 May 2006 07:13:08 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-27234</guid> <description>If  my  primary key is Auto increament then what happens when it crosses  its upper limit ? How to find the upper limit ?</description> <content:encoded><![CDATA[<p>If  my  primary key is Auto increament then what happens when it crosses  its upper limit ?<br /> How to find the upper limit ?</p> ]]></content:encoded> </item> <item><title>By: Eugene</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-27090</link> <dc:creator>Eugene</dc:creator> <pubDate>Mon, 22 May 2006 23:35:06 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-27090</guid> <description>Hey Liew, thanks for that piece of infomation,  but i am looking at how to renumber the ID instead.Example, i have 7 records and i deleted ID 4 and ID 5, so i would like to renumber all the ID and so that the last auto number is 5.</description> <content:encoded><![CDATA[<p>Hey Liew, thanks for that piece of infomation,  but i am looking at how to renumber the ID instead.</p><p>Example, i have 7 records and i deleted ID 4 and ID 5, so i would like to renumber all the ID and so that the last auto number is 5.</p> ]]></content:encoded> </item> <item><title>By: Marvin</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-17224</link> <dc:creator>Marvin</dc:creator> <pubDate>Thu, 02 Feb 2006 20:26:21 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-17224</guid> <description>Thanks ALOT! this helped me sooo much !</description> <content:encoded><![CDATA[<p>Thanks ALOT! this helped me sooo much !</p> ]]></content:encoded> </item> <item><title>By: Peter</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-14887</link> <dc:creator>Peter</dc:creator> <pubDate>Sat, 29 Oct 2005 12:43:17 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-14887</guid> <description>Thanks a lot for writing this down and publishing it.I found you via Google with a search of mysql auto_increment reset and it was precisely the piece of information I needed.@moo_t - why reset primary key? In my NucleusCMS I would like to publish a new blog (the fourth one). The blogid is visible in the url as index.php?blogid=x.As I had setup new blogs and deleted them, my supposed blog nr. 4 had blogid=7. It may be a cosmetic change, but from a users point of view (and from mine too) it&#039;s just not logical if blog nr. 4 has id nr. 7 ;-)</description> <content:encoded><![CDATA[<p>Thanks a lot for writing this down and publishing it.</p><p>I found you via Google with a search of<br /> mysql auto_increment reset<br /> and it was precisely the piece of information I needed.</p><p>@moo_t &#8211; why reset primary key?<br /> In my NucleusCMS I would like to publish a new blog (the fourth one). The blogid is visible in the url as index.php?blogid=x.</p><p>As I had setup new blogs and deleted them, my supposed blog nr. 4 had blogid=7. It may be a cosmetic change, but from a users point of view (and from mine too) it&#8217;s just not logical if blog nr. 4 has id nr. 7 <img src='http://www.liewcf.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Ray</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-13287</link> <dc:creator>Ray</dc:creator> <pubDate>Mon, 26 Sep 2005 08:19:51 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-13287</guid> <description>I have the same problem...I want to do this because I will run out of records after a few months/years.</description> <content:encoded><![CDATA[<p>I have the same problem&#8230;</p><p>I want to do this because I will run out of records after a few months/years.</p> ]]></content:encoded> </item> <item><title>By: moo_t</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-1845</link> <dc:creator>moo_t</dc:creator> <pubDate>Wed, 06 Oct 2004 12:13:14 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-1845</guid> <description>Just don&#039;t understand in what circumstances you want to reuse the Primary key.And for sorting, btree table is good enough for daily usage.</description> <content:encoded><![CDATA[<p>Just don&#8217;t understand in what circumstances you want to reuse the Primary key.</p><p>And for sorting, btree table is good enough for daily usage.</p> ]]></content:encoded> </item> <item><title>By: tkh</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-234</link> <dc:creator>tkh</dc:creator> <pubDate>Sun, 18 Apr 2004 03:56:54 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-234</guid> <description>SQL not a problem to me... thks for ur advice :)</description> <content:encoded><![CDATA[<p>SQL not a problem to me&#8230; thks for ur advice <img src='http://www.liewcf.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: LcF</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-220</link> <dc:creator>LcF</dc:creator> <pubDate>Fri, 16 Apr 2004 05:48:42 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-220</guid> <description>if you know SQL then MySQL is not a problem to you. :) just sometimes need to refer to its specified commands..</description> <content:encoded><![CDATA[<p>if you know SQL then MySQL is not a problem to you. <img src='http://www.liewcf.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br /> just sometimes need to refer to its specified commands..</p> ]]></content:encoded> </item> <item><title>By: tkh</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-217</link> <dc:creator>tkh</dc:creator> <pubDate>Fri, 16 Apr 2004 03:56:21 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-217</guid> <description>Havent learn mysql yet. going to start after my final. always take extra subject in every sem, after minus all my assignment + project.. dont have much space for me to learn other knowledge..</description> <content:encoded><![CDATA[<p>Havent learn mysql yet. going to start after my final. always take extra subject in every sem, after minus all my assignment + project.. dont have much space for me to learn other knowledge..</p> ]]></content:encoded> </item> <item><title>By: LcF</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-201</link> <dc:creator>LcF</dc:creator> <pubDate>Thu, 15 Apr 2004 08:47:34 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-201</guid> <description>the first condition to use insert_id is you must provide the auto increament value that you want to use. Do you mean that whenever you insert a new record, the new record will fill in the gap(s)? I have no idea about it yet and I don&#039;t think it is good idea to do so. In what situation you need insert record like this?Or, do you mean sort the records accordingly? Maybe you can do like this: Get the total number of records. Run a for loop, check the auto increament column value against loop seed. Alter the column value if not match.</description> <content:encoded><![CDATA[<p>the first condition to use insert_id is you must provide the auto increament value that you want to use.<br /> Do you mean that whenever you insert a new record, the new record will fill in the gap(s)? I have no idea about it yet and I don&#8217;t think it is good idea to do so. In what situation you need insert record like this?</p><p>Or, do you mean sort the records accordingly? Maybe you can do like this: Get the total number of records. Run a for loop, check the auto increament column value against loop seed. Alter the column value if not match.</p> ]]></content:encoded> </item> <item><title>By: spoonfork</title><link>http://www.liewcf.com/archives/2004/04/mysql-reset-auto-increament-number/comment-page-1/#comment-200</link> <dc:creator>spoonfork</dc:creator> <pubDate>Thu, 15 Apr 2004 08:21:07 +0000</pubDate> <guid isPermaLink="false">http://www.liewcf.com/wp/archives/2004/04/mysql-reset-auto-increament-number/#comment-200</guid> <description>yeah, but how would you automatically locate the gaps in insert_id if the records are deleted randomly?</description> <content:encoded><![CDATA[<p>yeah, but how would you automatically locate the gaps in insert_id if the records are deleted randomly?</p> ]]></content:encoded> </item> </channel> </rss><!--
This site's performance optimized by W3 Total Cache:

W3 Total Cache improves the user experience of your blog by caching
frequent operations, reducing the weight of various files and providing
transparent content delivery network integration.

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk

Served from: server.frens.net @ 2009-11-21 21:10:54 -->