Database center table insertion in disorder, database table insertion

Source: Internet
Author: User

Database center table insertion in disorder, database table insertion

1. symptom

Insert several rows of data into an intermediate table, but the inserted data is not inserted in the order of insertion.

Intermediate table: When database tables have many-to-many relationships, an intermediate table is required to correspond their relationships.

2. Table Structure

Because it is an intermediate table with no primary key, there are only two primary keys.

3. My attempt

Remove all transactions. inserting a transaction will help me to reorder the possibility. I wrote a for loop, which is very simple in the for loop, but simply inserts data into the database for One-Step debugging, view changes in the database.

The result is: the data is added in the order of the for loop, but the order is indeed out of order. However, the inserted sorting is regular and ordered alphabetically by ASCII code.

4. Cause

This table is indexed, probably because there is no primary key. when data is inserted, it is similar to the index method. Data is reordered and then inserted, sorted in ascending ASCII code order, same as index. In fact, after this table is indexed, it is equivalent to an index table. There is no need to create a new index table. Maybe mysql has done this kind of optimization.

Thank you!

 

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.