MySQL Forums
Forum List  »  Newbie

How to create a solid sequence?
Posted by: Gary Golden
Date: June 24, 2011 08:49AM


I have a field (int) which is autoincremented.
I need to make the sequence consistent, without holes.

For example, if we run:

("bar"), -- 1
("baz"), -- 2
("qux"); -- 3
DELETE FROM test WHERE id = 2;
INSERT INTO test SET foo="quux";

I need last insert have id 2, not 4.
I.e. mysql should somehow search for free values "between" and use it.

Is it possible with auto_increment?
If not, any suggestion how to SELECT first free value?

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.