In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how mysql sets the primary key of a data table and how to grow itself. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
Mysql sets the primary key of the data table and the method of self-growth: first start MySQL, open navicat to establish a new table; then add fields and types; then execute relevant statements to insert data; finally, select the field and tick before the Auto Increment below for self-growth.
Mysql sets the primary key and self-growing method of the data table:
1. Start MySQL, open navicat, create a new database aaa, right-click Tables, select new table, and create a new table.
2. Add field xsid with type int, and add field xsname with type vachar. As shown in the figure, select the field xsid and set it as the primary key by clicking Primary Key, or the location of 2 in the figure. Save the table with the name xstable.
3. Open the table xstable, create a new query, and enter the sql statement in the diagram. After successful execution, a piece of data is inserted into the table.
4. Set the xsid value in sql to empty, and the first execution of the statement can be successful. Xsid stores 0 by default, and an error will be reported when it is executed the second time, as shown in the figure. You can see that if the specific value of xsid cannot be set, it cannot be executed successfully.
5. Open the design interface of table xstable, select the xsid field, and tick the Auto Increment below, that is, select automatic growth.
6. On the query page, if you execute the sql statement with empty xsid again, it will be executed successfully and can be executed multiple times. Open the xstable table, look at the data, and find that multiple pieces of data have been successfully inserted, and the XSID value automatically increases by 1 at a time. After setting the growth, sql can also ignore the xsid field and write it directly in the form of figure 3.
7. Open the design interface of table xstable, and the value set by Auto Increment in the chart is the initial value of automatic growth.
Thank you for reading! About the mysql setting data table primary key and self-growth method to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.