472,143 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

Resetting AUTO_INCREMENT after deleting records

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
Aug 30 '07 #1
3 1622
code green
1,726 Expert 1GB
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.
Aug 30 '07 #2
r035198x
13,262 8TB
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.
Aug 30 '07 #3
pbmods
5,821 Expert 4TB
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.
Aug 30 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Pjotr Wedersteers | last post: by
reply views Thread by Miguel Perez | last post: by
9 posts views Thread by Bart Van der Donck | last post: by
5 posts views Thread by rameshkumarc | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.