Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to auto-increment column value starting from value other than one in mysql?

i have an existing mysql table with the id column defined as primary, and auto-increment set as true. now, i would like to know if i can set the auto-increment to start from a predefined value, say 5678, instead of starting off from 1.

I would also like to know if i can set the steps for auto-incrementing, say increase by 15 each for each new record insertion (instead of the default increment value of 1).

Note- i am using phpmyadmin to play with the db, and i have many tables but only one db.

Thanks.

like image 863
arun nair Avatar asked Dec 29 '25 02:12

arun nair


1 Answers

ALTER TABLE tbl AUTO_INCREMENT = 5678 will set the auto increment to 5678 for that table. Have a look at the detailed information here.

like image 160
James Allardice Avatar answered Dec 31 '25 16:12

James Allardice