Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reset autoincrement counter

Status
Not open for further replies.

PrograMan

Programmer
Jul 21, 2001
59
US
I set up a table with 5 columns (the number doesn't matter so much), the first one I have set to autoincrement. I have tested the table with INSERT and DELETE queries and have been successful with the tests. I've noticed, however, as the rest of you probably know, that even though I've deleted rows, the first column continues counting, even if the previous row was deleted. How do I reset the counting, if possible?
 
I'm not totally sure what you mean here, but the best you can do is reset the auto_increment value to one greater than the highest value (otherwise mySQL would try and overwrite the value when it found it in an existing record).

Use phpMyAdmin, enter your tables structure and choose Operations from the tabs.
 
what you should do is completely ignore the value of the auto increment column. whether it is at 50 or 45436438 should not matter as far as your data goes. gaps in the sequence of numbers also should not matter.
 
I have setup a table with an autoincrement field solely to supply an application with consecutive numbers for new accounts. The application calls a GetNewAccountNo function, which basically deletes all records from the table then inserts a new record thus supplying the latest incremented number.
This has been working flawlessly for 6 months, but suddenly the autoincrement reset to 0 and started again from there. Is there anything wrong with my approach? I am new to MySQL, and work for a small company where nobody else has access to the database, or the nous to deliberately sabotage the data.
The platform I am working on is MySQL version 5.0.45-community-nt, InnoDB tables, XP pro, Delphi 5, CoreLab MyDac data access components.
 
Sorry, tried to post a new item and it ended up as a reply to yours. Confusing interface???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top