MySQL can use auto_increment to set the value of the primary key is self growth, its default value is 1, if you want to set its initial value to 1000, the more stupid way is to insert a record and specify the primary key value of 999, and then delete the row record, for example:
The code is as follows |
Copy Code |
INSERT into Test (PK) values (999); Delete from test where PK = 999; |
A better approach is to use Alter's method to modify directly, for example:
The code is as follows |
Copy Code |
ALTER TABLE Test auto_increment = 200; |
Resets the initial value of the primary key for MySQL in addition to the test data. When you delete a data entry with a self-added property primary key in MySQL, you want to restore the primary Key's self-added initial value to a value the next time you insert the data, you can do this:
The code is as follows |
Copy Code |
ALTER TABLE TableName Auto_increment=1
|
(Reset initial value to 1)