Results 1 to 4 of 4
Oct 24, 2001, 06:39 #1
MySQL auto_increment and phpMyAdmin
If I have set the ID column of a table created in MySQL to auto_increment primary key, then how can I get MySQL to start it's counting at the highest number in the DB, and auto_increment from there on, rather than, as it does at the moment, start it's counting at the last value inserted, regardless of whether that value had later been deleted.
How do I change this?
Oct 24, 2001, 11:49 #2
There is no way to do that as far as I can tell just with mysql (there might be a way to do it, but I can't think of one right off the top of my head).
In the mysql documentation, it says that that is the way that auto_increment works, the only way for it to restart from scratch is deleting everything. I don't think you can do:
Delete row with ID = 4, then add a new row where the ID will be 4, if you add a new row, the ID will be 5
Oct 24, 2001, 12:08 #3
- Join Date
- Aug 2000
- San Diego, CA
- 0 Post(s)
- 0 Thread(s)
Thats correct, the reason is the auto_increment number is only a number to refer to the record only, meaning if you have relations in other tables with those ids, you don't want them overriding existing relations once a record is deleted. Follow me?Please don't PM me with questions.
Use the forums, that is what they are here for.
Oct 25, 2001, 02:59 #4
I understand your reason completely, it is just from creating a database from scratch it is a bit annoying that I can't just 'undo' a review.
But hey, it isn't very important.
Cheers for the help,