简体   繁体   English

Java中executeBatch不能维护的记录顺序

[英]Order of records not maintained by executeBatch in Java

I am inserting number of records in database its inserting correctly, but the order of the records not maintained. 我在数据库中正确插入了一些记录,但是记录的顺序未得到维护。 So is there any solution to solve this problem except ORDER BY clause. 因此,除了ORDER BY子句外,是否有解决此问题的解决方案。

There's no such thing like order of the records in a database. 没有像数据库中的记录顺序这样的东西。 When using a SELECT without ORDER BY, the database returns the rows in an arbitrary order. 当使用不带ORDER BY的SELECT时,数据库将以任意顺序返回行。

If you're unlucky enough, it returns them in the insertion order. 如果您不够幸运 ,它将按插入顺序返回它们。 Everything's fine... until some day a table compaction or whatever happens and the order is gone. 一切都很好...直到有一天表压缩或发生任何事情并且订单消失了。

Never rely on it. 永远不要依赖它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM