Android/SQLite: 将默认排序顺序设置回 ROWID 的方法
Android/SQLite: Way to set default sort order back to ROWID
我的应用程序出现问题,因为 SQLite 以某种方式改变了默认排序顺序的行为。
直到 SQLite 3.7.5(至少)当查询没有 "ORDER BY" 子句时,结果按 rowid 排序。现在在 SQLite 3.8.6 中,它们按主键排序。
SQLite 3.7.5:
select rowid, id, name from users;
rowid id name
--------------------
1 10 John
2 15 Peter
3 11 Mary
4 14 Sam
SQLite 3.8.6:
select rowid, id, name from users;
rowid id name
-------------------
1 10 John
3 11 Mary
4 14 Sam
2 15 Peter
我有无数的查询要更改,我只需添加 "ORDER BY ROWID"。
SQLite 是否有一个参数,我可以在其中将默认排序顺序设置回 ROWID?
SQLite makes no guarantees about the order of results if a SELECT omits the ORDER BY clause. Even so, the order of results does not change from one run to the next, and so many applications mistakenly come to depend on the arbitrary output order whatever that order happens to be. However, sometimes new versions of SQLite will contain optimizer enhancements that will cause the output order of queries without ORDER BY clauses to shift. When that happens, applications that depend on a certain output order might malfunction.
我的应用程序出现问题,因为 SQLite 以某种方式改变了默认排序顺序的行为。
直到 SQLite 3.7.5(至少)当查询没有 "ORDER BY" 子句时,结果按 rowid 排序。现在在 SQLite 3.8.6 中,它们按主键排序。
SQLite 3.7.5:
select rowid, id, name from users;
rowid id name
--------------------
1 10 John
2 15 Peter
3 11 Mary
4 14 Sam
SQLite 3.8.6:
select rowid, id, name from users;
rowid id name
-------------------
1 10 John
3 11 Mary
4 14 Sam
2 15 Peter
我有无数的查询要更改,我只需添加 "ORDER BY ROWID"。
SQLite 是否有一个参数,我可以在其中将默认排序顺序设置回 ROWID?
SQLite makes no guarantees about the order of results if a SELECT omits the ORDER BY clause. Even so, the order of results does not change from one run to the next, and so many applications mistakenly come to depend on the arbitrary output order whatever that order happens to be. However, sometimes new versions of SQLite will contain optimizer enhancements that will cause the output order of queries without ORDER BY clauses to shift. When that happens, applications that depend on a certain output order might malfunction.