Re: Re: phpMyAdmin--resetting auto increments to 0

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

 



tedd wrote:

At 3:01 PM -0600 4/16/06, Chuck Anderson wrote:
tedd wrote:

At 1:42 PM -0600 4/16/06, Chuck Anderson wrote:

alex wrote:

hi everyone

i have delete a few entries in my database as they were entered for testing purposes and are no longer need (actually 102 entries)... and even thought that db is empty i noticed that when the next entry went in the id number went to 103 not 0 so i was wondering is it possible to somehow reset the value to zero...

it is of int type and auto_increment

i have a few db's which id like to reset to zero i have tried placing a zero enrty after deleting the lot but it only jumps to its next increment.
does anyone know what i mean...?
any help will be grateful
regards alex
On a related note (he did say PhpMyAdmin) ...

ALTER TABLE 'tablename' auto_increment=n works, but I can't get PhpMyAdmin to reset the auto_increment through the Operations menu page.

If I go to the Operations tab for a table and set the auto_increment value to something less that it currently is, PhpMyAdmin will not honor my request and re-specifies the current auto_increment value in the ALTER TABLE command (even though my requested value is valid).

Is this because of a config setting? I could have sworn earlier versions would obey my request.
Chuck:

This always works for me in PhpMyAdmin (I mistyped it before).

1. Delete the first record.
2. Reset the auto_increment in Operations to whatever you want.
3. Insert a record.
4. Delete that record.

After that, the next record will start at the new auto_increment value. Don't ask why, that's just the way it works.

tedd

That would work, except that I want to change the auto_increment without deleting the first record.

During testing I may add many entries to the end of an existing database table. When I am done testing I want to delete those "extraneous" entries (leaving the earlier entries intact). Call me obsessive/compulsive or whatever, but I like to knock the auto_increment value back down to the next valid value (what was the first "test" value).

PhpMyAdmin refuses to use the valid auto_increment value I specify in Operations and I have to edit the query to set it right.


Chuck:

Okay, then delete whatever record you want and reset the auto_increment value to that -- for example: Let's say you have records 0 - 100 that you want to keep. Then you added some test records that went from 101 to 150 and now you want to delete those records and start again at 101, right?

Simple, just:

1. Delete records 101-150.
2. Reset the auto_increment in Operations to 101
3. Insert a false record.
4. Delete that false record.

Now, your dB will be set to start at 101.

What's even more amazing (at least I've found), is that if you had 0-100 records you wanted to keep and 101-150 you wanted to delete, but also had 151 to 200 you also wanted to keep, you could do what I said above and the auto_increment would fill up 101-150 and then jump to 201. It's neat the way it works. At least that's my memory. Try it.

tedd
I appreciate your help here ..... but ....

2. Reset the auto_increment in Operations to 101

That's the part that PhpMyAdmin refuses to do. It will not alter it to less than 151 (per your example).

PhpMyAdmin 2.6.4-pl3

It's not much work to then edit the PhpMyAdmin query to my liking, but I don't think I used to have to do that.

I like your second part about filling in the between stuff. If I'm at that point, though, I delete the auto_increment field (sorting the table by date) and then add it back in. That fills all the gaps, too.

What I want to know is why PhpMyAdmin will not do your step 2. I swear that earlier versions would let me do that.

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
****************************

--
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