0

I have a file company.txt with 2 columns:

1   Angola
2   Apple
3   Argentina
4   Facebook
5   Google
6   Twitter
7   Samsung
8   LinkedIn
9   Yahoo

At MySql command line, I executed:

LOAD DATA LOCAL INFILE `'company.txt' INTO TABLE Term FIELDS TERMINATED BY`;

select * from Term;
+----+-----------+
| id | name      |
+----+-----------+
|  1 | Angola    |
|  2 | Apple     |
|  3 | Argentina |
|  4 | Facebook  |
|  5 | Google    |
|  6 | Twitter   |
|  7 | Samsung   |
|  8 | LinkedIn  |
|  9 | Yahoo     |
+----+-----------+
9 rows in set (0.00 sec)

This all look fine. However, when the database tables are created through Hibernate in code this file is loaded through JBoss configuration file, the record order of the loaded file into the table is slightly different:

<property name="hibernate.hbm2ddl.auto" value="create-drop" />

The new order:

select * from Term;
+----+-----------+
| id | name      |
+----+-----------+
|  1 | Angola    |
|  2 | Apple     |
|  3 | Argentina |
|  4 | Facebook  |
|  5 | Google    |
|  8 | LinkedIn  |
|  7 | Samsung   |
|  6 | Twitter   |
|  9 | Yahoo     |
+----+-----------+

As you can see, the order is

1 2 3 4 5 8 7 6 9

Not

1 2 3 4 5 6 7 8 9

But the id -> name mapping is still right, although the record order is slightly different. Does this matter (ID not in sequential order)?

user697911
  • 10,043
  • 25
  • 95
  • 169
  • In absence of `ORDER BY` clause the order of records is inconsistent and meaningless. – PM 77-1 Mar 06 '16 at 03:55
  • So, this phenomena is normal. Right? Ideally, by default it should be loaded as the insertion order as in the original file. – user697911 Mar 06 '16 at 04:02
  • http://stackoverflow.com/questions/11656476/mysql-order-by-insertion-order-no-sorting-columns – PM 77-1 Mar 06 '16 at 04:37

0 Answers0