Jump to content

[SOLVED] question about auto increment in MySQL


webguync

Recommended Posts

Say you have a table with a field called ID set as Type(smallint), and set to auto increment. You have 10 entries, 1-10 in the ID field. You delete the entries, and start adding new ones. Even though there are currently no entries, the new additions will begin 11,12,13,14,15, and so on for the ID's. Is there a way to get the ID's to start over at 1 without manually going in to edit each one?

Link to comment
Share on other sites

Say you have a table with a field called ID set as Type(smallint), and set to auto increment. You have 10 entries, 1-10 in the ID field. You delete the entries, and start adding new ones. Even though there are currently no entries, the new additions will begin 11,12,13,14,15, and so on for the ID's. Is there a way to get the ID's to start over at 1 without manually going in to edit each one?

Why does everyone want to do this?

 

This is NOT a counter.

 

This is a unique row identifier -- never to be re-used.

 

Oh, and you'll kick yourself later for using SMALLINT -- use UNSIGNED INT instead.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.