带有偏移量的sqlite3限制在android中不起作用

时间:2018-05-15 14:05:15

标签: sqlite

select * from <table_name> limit 100 offset 200; 

预期的结果是它应该返回201到300的行。但是在android中它返回的行从2到101.

sqlite> create table test (id integer primary key autoincrement, name text);
sqlite> insert into test (name) values('a');
sqlite> insert into test (name) values('a');
sqlite> ...
sqlite> select * from test limit 10 offset 2;
2|a 3|a 4|a 5|a 6|a 7|a
sqlite> select * from test limit 10 offset 5;
2|a 3|a 4|a 5|a 6|a 7|a
sqlite> select * from test limit 2 offset 5;
2|a 3|a
sqlite> select * from test limit 5,3;
2|a 3|a 4|a

sqlite> EXPLAIN SELECT * FROM test LIMIT 2 OFFSET 5;
addr  opcode         p1    p2    p3    p4             p5  comment      
----  -------------  ----  ----  ----  -------------  --  -------------
0     Init           0     14    0                    00               
1     Integer        2     1     0                    00               
2     Integer        5     2     0                    00               
3     MustBeInt      2     0     0                    00               
4     OffsetLimit    1     3     2                    00               
5     OpenRead       0     383   0     2              00               
6     Rewind         0     13    0                    00               
7       IfPos          2     12    1                    00               
8       Rowid          0     4     0                    00               
9       Column         0     1     5                    00               
10      ResultRow      4     2     0                    00               
11      DecrJumpZero   1     13    0                    00               
12    Next           0     7     0                    01               
13    Halt           0     0     0                    00               
14    Transaction    0     0     44    0              01               
15    Goto           0     1     0                    00               
sqlite>

sqlite> .schema test
CREATE TABLE test (id integer primary key autoincrement, name text);

sqlite> PRAGMA table_info(test);          
0|id|integer|0||1
1|name|text|0||0
sqlite>

我们需要在编译sqlite3 for android时启用任何标志吗?

0 个答案:

没有答案