Last Updated on: September 16, 2022
If you want to reseed your primary key (i.e. change the value of the next primary key generated), you can do it like this:
ALTER TABLE table_name AUTO_INCREMENT = 59446;
This is useful for starting a new site, and you don’t want to leave hints that you have just launched.
For example, if you sign up a new user whose user_id is 3 and they can see it (e.g. in the URL), then they can easily figure out you are new.
This is increasingly important for eCommerce, where customer confidence is essential. Re-seed your invoice/order numbers if they are based on primary keys, and it will look like you have been in business for years.
Get notified of new posts: