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!