Re: Inserting rows with missing IDs
| From: | Nathan Rixham | Date: | Wed, 05 May 2010 03:58:43 +0000 |
| Subject: | Re: Inserting rows with missing IDs | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-304896@lists.php.net to get a copy of this message | ||
Richard Quadling wrote:
On 3 May 2010 14:34, Andre Polykanine <andre@oire.org> wrote: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, nathanHello 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)