MySQL Forums :: Newbie :: How to create a solid sequence?


Advanced Search

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

Hello.

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

For example, if we run:

INSERT INTO test(foo) VALUES
("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


Subject Written By Posted
How to create a solid sequence? Gary Golden 06/24/2011 08:49AM
Re: How to create a solid sequence? Peter Brawley 06/24/2011 09:49AM
Re: How to create a solid sequence? Gary Golden 06/24/2011 10:27PM
Re: How to create a solid sequence? Gary Golden 06/24/2011 11:05PM
Re: How to create a solid sequence? Rick James 06/24/2011 11:11PM
Re: How to create a solid sequence? Guelphdad Lake 06/24/2011 10:58PM
Re: How to create a solid sequence? Peter Brawley 06/25/2011 06:26AM
Re: How to create a solid sequence? Gary Golden 06/24/2011 11:35PM
Re: How to create a solid sequence? Gary Golden 06/24/2011 11:59PM
Re: How to create a solid sequence? Barry Galbraith 06/25/2011 12:46AM
Re: How to create a solid sequence? Gary Golden 06/25/2011 12:52AM
Re: How to create a solid sequence? Guelphdad Lake 06/25/2011 06:57AM


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.