On Sat, 2002-08-17 at 00:30, Louis Selvon wrote: > Hi Slugs: > > I have a question regarding MySQl auto increment index. > > When I create a table and set a field to "auto increment", does anyone > know how can I reset the index to start at value "1" after I have deleted > all data from that table.
Depending on your table type and the delete statement, this may happen automatically. > At present as an e.g, I initially had 10 records. The index started from 1 and > went up to 10. After I deleted all the data from the table, and entered a new > set, the index started from "11" and not "1" . > > I am concerned that after the maximum index value is reached for the data type > selected for auto increment (at present I chose "int 11"), does MySQL resets > the start of the new record to "1" ? No idea. > > Is there a way for me to tell MySQL to reset the index to number "1" or any > starting value for that matter, when all records are deleted and new ones are > entered. ALTER TABLE tablename AUTO_INCREMENT=x; The above statement seems to have a few limits to it though. You can always delete/copy the column and recreate/modify it before making it a key. -- SLUG - Sydney Linux User's Group - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug
