primary key - Mysql Myisam re-using auto-incremented ids that are deleted -


i have table: test

id int(10) auto-increment name char(36)

now let whole table filled id 1000 => max unique id number. id 1 - 1000 = deleted previously.

question 1; mysql re-use these deleted id's? question 2; if not, how go having auto-increment or whatever re-use unique identifier not exist in table?

the reason asking, table consist of alot of entries, , alot of entries deleted time. happens when "run-out-of-id" when using auto-increment?

thanks enlightment on :)

-tom

  1. will mysql re-use these deleted id's?

    when mysqld starts, determines next value every auto_increment column finding maximum of incumbent records (and adding 1). therefore, if delete record highest value , restart server, deleted id indeed reused.

    otherwise, values reused if manually alter next auto_increment value (this not recommended not concurrency-safe):

    alter table foo auto_increment = 12345; 
  2. if not, how go having auto-increment or whatever re-use unique identifier not exist in table?

    generally speaking, don't: consider redesigning data structure inserts/deletes not happen in fashion, or else use larger integer type (bigint unsigned 8 bytes, can go 2^64 or ~10^19).

  3. what happens when "run-out-of-id" when using auto-increment?

    as stated in the manual:

    use smallest integer data type auto_increment column large enough hold maximum sequence value need. when column reaches upper limit of data type, next attempt generate sequence number fails.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -