Connecting Tech Pros Worldwide Help | Site Map

Resetting AUTO_INCREMENT after deleting records

Newbie
 
Join Date: Aug 2007
Posts: 1
#1: Aug 30 '07
I add a column named deptid in my dept table which is auto incremented.
After adding 3 records I deleted those records and inserted another record.
But it take the deptid as 4. I want it to start from 1.
If U know how to do this pls help.

Best Regards
code green's Avatar
Expert
 
Join Date: Mar 2007
Location: England
Posts: 1,076
#2: Aug 30 '07

re: Resetting AUTO_INCREMENT after deleting records


Quote:
After adding 3 records I deleted those records and inserted another record.
But it take the deptid as 4. I want it to start from 1.
OK but why? This is what auto-number does.
If you want to define the id yourself, don't use auto-number.
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#3: Aug 30 '07

re: Resetting AUTO_INCREMENT after deleting records


Quote:

Originally Posted by sasheena

I add a column named deptid in my dept table which is auto incremented.
After adding 3 records I deleted those records and inserted another record.
But it take the deptid as 4. I want it to start from 1.
If U know how to do this pls help.

Best Regards

See the post #2 by Atli in this thread.
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#4: Aug 30 '07

re: Resetting AUTO_INCREMENT after deleting records


Note that MySQL doesn't care whether the ID of the first record is 1, 6 or 548633. Forcing MySQL to reset the AUTO_INCREMENT value of a table will not improve performance.
Reply