Is there a better way to reset the auto_increment in a table, basically
there are several million rows in the database and the field that is
auto_increment is very large now and I don't want to exceed the limit of
the field description so I want to renumber all the rows starting at 1
again.

 

What I found online was this:

 

For those that are looking to "reset" the auto_increment, say on a list
that has had a few deletions and you want to renumber everything, you can
do the following.

DROP the field you are auto_incrementing.
ALTER the table to ADD the field again with the same attributes.

You will notice that all existing rows are renumbered and the next
auto_increment number will be equal to the row count plus 1.

 

 

So is there an easier / better way to do this? Also would the way this is
done be different if the table is empty?? I have an empty table that when
I add a record, starts at some number based on how many have been entered
and deleted.

 

Chris Hood 

Investigator Verizon Global Security Operations Center 

Email:  <mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED] 

Desk: 972.399.5900

Verizon Proprietary

                                    

NOTICE - This message and any attached files may contain information that
is confidential and/or subject of legal privilege intended only for the
use by the intended recipient.  If you are not the intended recipient or
the person responsible for delivering the message to the intended
recipient, be advised that you have received this message in error and
that any dissemination, copying or use of this message or attachment is
strictly forbidden, as is the disclosure of the information therein.  If
you have received this message in error please notify the sender
immediately and delete the message.

 

Reply via email to