Home >Database >Mysql Tutorial >How to set auto-increment id in mysql
Mysql method to set auto-increasing id: First create the database, select Create Table; then when designing the table fields, the last parameter AI of the id column is auto-increasing, just check it.
The operating environment of this tutorial: windows7 system, mysql8.0.22, thinkpad t480 computer.
Related free learning recommendations: mysql database(Video)
##mysql Method to set auto-increment id:
1. Open MySQL Workbench, create a database, right-click Tables, and select Create Table 2 . When designing table fields, the last parameter AI (Auto Increment) of the id column is auto-increment. Just check it. It should be noted that it must be defined as INT type and must be set as an index. In this example, id is set as the primary key and defaults to the primary key index. 3. Execute Apply to create the table 4. You can also create the table through SQL commands 5. After the creation is successful, we insert a record and observe that the id column automatically grows to 1 6. In mysql, we can manually assign values to self-increasing columns 7. After assignment, the records that will self-increase in the future will be based on our assignment. 1, here should be the maximum Based on the value 1 8. If you want to clear the table and start assigning values again, you need to execute the truncate commandRelated free learning recommendations:php programming (video)
The above is the detailed content of How to set auto-increment id in mysql. For more information, please follow other related articles on the PHP Chinese website!