List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:September 12 2005 12:59pm
Subject:Re: innoDB and autoincrement
View as plain text  
At 15:17 +0530 9/12/05, priya.soma@stripped wrote:
>  This is from the docs ..... "The auto-increment value of a deleted 
>record will only not be reused until the server is restarted, then 
>it will be reused. In other words, if you insert 10 rows into an 
>InnoDB table and then delete them the AUTO_INCREMENT value will stay 
>at 11 until the server is shutdown at which point it will revert to 
>1!!!""
>
>Now if i have records 1 to 10 and i delete some records in between , 
>say, 5, 7, 8. Now when i restart my server, will these values of 5, 
>7 and 8 be reused??

No. If there is a value present in the column with a value higher than the
unused values, those values won't be reused.

>
>Does it mean that the autoincrement values of deleted records will 
>be reused only if ALL records are deleted and then server restarted??

All records with values higher than the deleted records.

>
>From docs .... "  Note that you may see gaps in the sequence of 
>values assigned to the AUTO_INCREMENT column if you roll back 
>transactions that have gotten numbers from the counter.  "
>Does InnoDB reuse these gap  values at any time ???

If all records with values higher than the deleted records are deleted
and you restart.

-- 
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
Thread
innoDB and autoincrementpriya.soma12 Sep
  • Re: innoDB and autoincrementMichael Stassen12 Sep
  • Re: innoDB and autoincrementGleb Paharenko12 Sep
  • Re: innoDB and autoincrementPaul DuBois12 Sep