I have an order table in mysql database and need to make the OrderId field entry start from a 5 figure number with an increment of 1. Any ideas how I can do this?
Make sure of the version -- it makes a difference.
MySQL version 4.x supports the statement:
alter table <tablename> auto_increment = <starting number>;
In MySQL 3.x, if you insert a record and set a value for the auto_increment column, the server will begin generating auto_incrmement numbers from that value. It's the only way to set a starting value.
You can then delete that record, but do not perform a "DELETE from <tablename>" query that does not have a WHERE clause. MySQL, in order to speed "DELETE from <tablename>" queries, will drop and recreate the table, which will reset the auto_increment start value back to 1.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.