Re: Inserting rows with missing IDs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3 May 2010 14:34, Andre Polykanine <andre@xxxxxxxx> 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)



--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux