On Tue, 24 May 2005 [EMAIL PROTECTED] wrote:

>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.


In the case that the table is empty the information here

http://dev.mysql.com/doc/mysql/en/set-option.html


should let you do what you want.


I don't know the best way to 're-index' existing data. 


>
> 
>
>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.
>
> 
>
>


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to