问题描述
描述:通过Excel导入数据,解析后放入list集合中,集合中数据的顺序和excel导入时的一致,通过批量添加到数据库中,出现的结果是数据库中的数据是无序的(也就是和excel导入时的顺序不一致).求解... 问题补充:xianshi_cn 写道
解决方案
I have met the same issue before in Oracle, but I also don't know how come the the physics orders of data changed while bulk insert.I prompted the issue to stackoverflow, and one expert replied me:引用A heap organized table is inherently unordered. Unless your query specifies an ORDER BY clause, Oracle is free to return data in whatever order it chooses. And it is free to physically store data in any order regardless of the order of inserts.So I think you have two options:[list] Give up bulk insert, and commit record one by one Add a serial number in your excel, and after importing ,use SELECT serial_number, name FROM your_table_name ORDER BY serial_numberto get the data[/list]
解决方案二:
Do you use Oracle db ?