How to Alter Sequence in MySQL

Auto incrementing columns in tables start at 1 by default, but sometimes you may want them to start at a different number. These numbers are known as "sequences" in other databases but are implemented differently in MySQL. An auto incrementing column is part of table definition and is modified using the ALTER TABLE command.

First, you can check for the next value using the SHOW CREATE TABLE COMMAND:

mysql> SHOW CREATE TABLE users\G;
*************************** 1. row ***************************
       Table: users
Create Table: CREATE TABLE `users` (
  `user_id` int(11) NOT NULL AUTO_INCREMENT,
   <<other lines omitted for brevity>>
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2

To change it:

ALTER TABLE users AUTO_INCREMENT=1000;
database icon
Real-time SQL collaboration is here
Get started with PopSQL and MySQL in minutes