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
will mysql re-use these deleted id's?
when
mysqldstarts, determines next value everyauto_incrementcolumn 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_incrementvalue (this not recommended not concurrency-safe):alter table foo auto_increment = 12345;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 unsigned8 bytes, can go 2^64 or ~10^19).what happens when "run-out-of-id" when using auto-increment?
as stated in the manual:
use smallest integer data type
auto_incrementcolumn large enough hold maximum sequence value need. when column reaches upper limit of data type, next attempt generate sequence number fails.
Comments
Post a Comment