Richard Quadling wrote:
On 3 May 2010 14:34, Andre Polykanine <an...@oire.org> wrote:
Hello everyone,
It's not a strictly PHP question, however since I use that with PHP,
I'm asking it there.
How can I accomplish the task of inserting rows into MySql database
with missing IDs? Say, I have rows with IDs 1, 2, 3, 5, 9, 12, 17, and
195. How do I make the check that allows to insert firstly the missing
IDs and only then apply the auto-increment?
Thanks!


You can also reseed the autoinc column back to 0 and that will start
filling in the gaps.

ALTER TABLE tablename AUTO_INCREMENT = 0

may work for you
(http://arstechnica.com/civis/viewtopic.php?f=20&t=123689 via
http://tinyurl.com/3amlo2u)


quite sure that once mysql hit's the max int limit it starts filling in the gaps too - like ~96.4% sure

have to agree though, one shouldn't have any dependency on sequential numbers (unless it's a number table!)

best,

nathan

And if they really want just a sequential number ID that they DO NOT depend upon, they can always drop the id from the table and then recreated it -- that way it will be automatically renumbered.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to