MySQL add data after the sorting in the database, how to solve

Source: Internet
Author: User
MySQL sorting in the database after adding data
The data added at the beginning is incremented. And then it became like this. eg. Id:9 8 7 1 2 3 4 5 6 What sort of row is this? How do we get him to increment correctly?

------Solution--------------------
Is the ID an auto-growing column?
------Solution--------------------
I think you have a problem with the query, or the query shows a problem
------Solution--------------------
SQL Code
SELECT * FROM table order by id desc;
------Solution--------------------
Explore

The normal SELECT * from ' AA ' is all sorted in order. But the display is a bit strange. Is the MySQL version of the problem?

------Solution--------------------
There is an action that can reproduce your effect

MyISAM table
Insert data, and then delete the smaller ID, this time the table will be fragmented, and then insert the data

SELECT * From ... It will lead to this order.

If you delete the data, the OPTIMIZE table won't do that.


I'm guessing this could be a physical location.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.