Setting Custom Auto-Increment Start Value in MySQL
When working with MySQL databases, it may be necessary to set a custom starting value for auto-increment columns. By default, MySQL auto-increments from the number 1, but it is possible to change this to any desired value.
Solution:
To alter the starting number for auto-increment columns, you can use the following MySQL query:
ALTER TABLE table_name AUTO_INCREMENT = starting_value;
For example, if you have a table named "tbl" and you want to set the auto-increment value to 5, you would execute the following query:
ALTER TABLE tbl AUTO_INCREMENT = 5;
This query will change the auto-increment starting value to 5 for the specified table. Subsequent insertions into this table will start from that value.
Additional Notes:
The above is the detailed content of How to Set a Custom Starting Value for Auto-Increment in MySQL?. For more information, please follow other related articles on the PHP Chinese website!