Modifying Auto-Increment Starting Value in MySQL
In MySQL, the auto_increment feature automatically assigns unique sequential numbers to new records in a table. By default, this increment starts from 1. However, there may be scenarios where you require a different starting value for the auto-increment sequence.
Query to Change Auto-Increment Starting Number
To change the auto_increment starting number, you can use the ALTER TABLE statement with the AUTO_INCREMENT clause. The syntax is as follows:
ALTER TABLE table_name AUTO_INCREMENT = new_starting_value;
For example, to set the auto-increment starting number to 5 for a table named tbl, you would run the following query:
ALTER TABLE tbl AUTO_INCREMENT = 5;
Details and Considerations
When executing this query, keep the following in mind:
Reference:
For further details and additional options, refer to the official MySQL documentation on [ALTER TABLE](https://dev.mysql.com/doc/refman/8.0/en/alter-table.html).
The above is the detailed content of How to Change the Auto-Increment Starting Value in MySQL?. For more information, please follow other related articles on the PHP Chinese website!