How to set auto_increment value in mysql? - Mysql Views : 763
Tagged in : Mysql
Send mail vote down 0 vote down 0
In mysql, default auto_increment value is 1 and if you want to change/set the auto_increment value then use the following.

mysql> set @@auto_increment_increment = 10;

It will set the default value of auto_increment from 1 to 10.

Likewise you can set value for "auto_increment_offset". Auto_increment_offset refers to the starting value of the auto_increment.Default starting value of auto_increment_offset is 1 and to change the default value use the following,

mysql> set @@auto_increment_offset = 10;

It will set the auto_increment_offset value from 1 to 10.

To view the changed value use the following,

mysql> show variables like 'a%';

it will result,




Variable_nameValue
auto_increment_increment10
auto_increment_offset10
automatic_sp_privilegesON

> Changed value will persist only till you exit mysql.
> If you exit and start mysql again, the value of auto_increment_increment will be 1 by default.
> Again you have to set the AUTO_INCREMENT value.

By - Ramya, On - 2008-05-29




    Login to add Comments .