SQLite Forum

Is the order conserved in a table from a VALUES clause?
Login
Neither. See also my comment below. This is the bytecode generated by SQLite 3.24.0:

asql> explain select * from (values  (1),(2),(3) );
addr  opcode         p1    p2    p3    p4             p5  comment
----  -------------  ----  ----  ----  -------------  --  -------------
0     Init           0     1     0                    00  NULL
1     InitCoroutine  1     9     2                    00  NULL
2     Integer        1     2     0                    00  NULL
3     Yield          1     0     0                    00  NULL
4     Integer        2     2     0                    00  NULL
5     Yield          1     0     0                    00  NULL
6     Integer        3     2     0                    00  NULL
7     Yield          1     0     0                    00  NULL
8     EndCoroutine   1     0     0                    00  NULL
9     InitCoroutine  1     0     2                    00  NULL
10      Yield          1     14    0                    00  NULL
11      Copy           2     4     0                    00  NULL
12      ResultRow      4     1     0                    00  NULL
13    Goto           0     10    0                    00  NULL
14    Halt           0     0     0                    00  NULL

The guarantee holds only as long as the code generator implements VALUES as a coroutine, and this prevents the pragma from affecting the order.