In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how mysql rearranges the id, I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article, so let's learn about it!
The method that mysql rearranges id: 1, use column count [alter table tablename drop column id]; 2, use increment to arrange [alter table tablenam auto_increment].
How mysql rearranges id:
When using mysql, there is usually a self-increasing id field in the table, but when we want to empty the data in the table and re-add data, we want id to start counting again from 1, either of the following two methods:
Method 1:
Alter table tablename drop column id;alter table tablename add id mediumint (8) not null primary key auto_increment first
Method 2:
Alter table tablename auto_increment=0
Method 2 will not clear the existing data, and the operation is more flexible, which can not only return the self-increment to zero, but also apply to reset the self-increment and insert new data after deleting a large number of consecutive rows, or start with a new value, of course, it can not conflict with the existing ones.
$sql= "delete from $table_vote"; mysql_query ($sql, $link); $sql= "alter table $table_vote auto_increment=1"; mysql_query ($sql, $link); these are all the contents of mysql's method of rearranging id. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more 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.
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.