|
|
How to set auto_increment value in mysql? - Mysql
|
Views : 763
|
|
Tagged in : Mysql
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
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_name | Value |
| auto_increment_increment | 10 |
| auto_increment_offset | 10 |
| automatic_sp_privileges | ON |
> 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 |
|
|
|