In MySQL, how can you change the starting value for the auto-increment column from the default 1 to a specific number, such as 5?
To modify the auto-increment starting value in MySQL, you can use the ALTER TABLE statement with the AUTO_INCREMENT keyword. The syntax is as follows:
ALTER TABLE tbl_name AUTO_INCREMENT = starting_value;
where:
For example, to set the auto-increment value to 5 for the id column in the tbl table, you would use the following query:
ALTER TABLE tbl AUTO_INCREMENT = 5;
This will change the starting value for the auto-increment sequence to 5, so the next inserted record will have an id of 5.
Additional Information:
The above is the detailed content of How to Change the Auto-Increment Starting Number in MySQL?. For more information, please follow other related articles on the PHP Chinese website!