In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail what is the relationship between primary key 0 and primary key self-arrangement constraint in MySQL, the content of the article is of high quality, so the editor shares it for you to do a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
The design of not setting the primary key table at the beginning is as follows:
If the position of id has several zeros: when you set the primary key and sort automatically, 0 will be incremented from 1
If Insert enters the data with id = 0, the data will increase from the actual number of rows, which is different from the change from 0.
Now the primary key does not have 0, if you change an id to 0, 0 will not change! Will be sorted directly.
Insert an id=0 to see that it is still as directly related to the number of lines as just now!
Reset the automatic sorting again to see if there will be any change in this zero. Cancel the automatic sorting first.
Plus self-arrangement, as expected, 0 is going to become 1, the error prompt is that the primary key has a duplicate 1, so do not allow self-arrangement.
After the revision, it really works. 0 becomes 1.
Summary
I think there should be no difference between unsigned situations. I hope you can leave a message for me if there is anything else you haven't considered. You can tell me what you think. I would also like to know. Now let me write down my summary and thoughts:
For me, 0 is special in the database.
When you use limit to view the specified range of data, the table will be sorted down from 0, but when insert adds a row of data, it has something to do with the number of rows, which is sorted down from 1. If there are zeros in the table before using the primary key self-permutation constraint, all zeros after setting the primary key selections will not be based on the number of rows, but will be ranked directly from 1 to 1 in top-down order. If you change the number of a primary key in the table to 0, it will be sorted directly in front of the positive number, that is to say, 0 is allowed to exist in the primary key self-arrangement, so why should the existing 0 be changed to an increasing sequence starting with 1? Even if there is only a 0 before adding the primary key, it will still become 1 after adding the primary key.
At the beginning, there is 0, and the primary key self-arranging constraint is increased, and 0 in turn becomes 1, 2, 3, 4.
If there is no 0 at the beginning, add the primary key self-arranging constraint. The rows with the newly added primary key of 0 will change according to the number of rows. Note that here are the newly added lines, using insert.
If there is no 0 at first, change the number of a primary key to 0, and the 0 will be directly sorted and displayed in the table.
To put it simply, after adding the primary key self-scheduling constraint:
The value of the primary key: modified to 0, can exist, that is, sort.
The newly added 0 is not allowed to exist and should be changed according to the line number.
The 0 that exists in itself is not allowed to exist, but should be changed incrementally from 1.
About the relationship between primary key 0 and primary key self-scheduling constraint in MySQL, I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.
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.