Reseed MySQL Primary Key – AUTO_INCREMENT

by Carey on November 26, 2010

Post image for Reseed MySQL Primary Key – AUTO_INCREMENT
  • Share
  • CevherShare
  • Share

If you want to reseed your primary key (i.e. change the value of the next primary key generated), use this handy MySQL function:

 ALTER TABLE table_name AUTO_INCREMENT = 59446; 

This is useful for when you are starting a new site and you want to disguise that fact. For example, if you sign up a new user and their user_id is 14 it is a giveaway that there are only a maximum of 13 other users.

{ 2 comments… read them below or add one }

ebe September 10, 2007 at 4:49 pm

Yeh, but the most of the readers are using phpMyAdmin.. and they could just click “Operations” -tab .. and set the AUTO_INCREMENT -value.

Reply

Carey September 10, 2007 at 5:33 pm

Good advice, I am personally not a fan of phpMyAdmin. Much prefer to do as much as I can in pure sql.

Reply

Leave a Comment

Previous post:

Next post: