Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of setting self-growing id by mysql

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the method of setting self-growing id in mysql, which is very detailed and has certain reference value. Friends who are interested must finish reading it!

Mysql sets the method of self-growing id: first create the database, select Create Table;, and then when designing the table field, the last parameter AI of the id column is self-growing, just check it.

Mysql: how to set self-growing id:

1. Open MySQL Workbench, create a database, right-click Tables, and select Create Table

2. When designing the table field, the last parameter AI (Auto Increment) of the id column is self-growing. Check it. It should be noted that it must be defined as an INT type and must be set to an index. In this case, id is set as the primary key and the default is the primary key index.

3. Execute Apply to create a table

4. You can also create a table by using the SQL command

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 assign values manually for self-growing columns.

7. The record of self-growth after assignment is + 1 on the basis of our assignment, which should be + 1 on the basis of the maximum value.

8. If you want to empty the table and start assignment again, you need to execute the truncate command

The above is all the content of this article "how to set up self-growing id in mysql". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report