Richard Quadling wrote:
On 3 May 2010 14:34, Andre Polykanine <an...@oire.org> wrote:
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?
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
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!)
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.
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