SQLite VDBE opcode

Rowid

Store in register P2 an integer which is the key of the table entry that P1 is currently point to.

An example

59 of the 178 statements we compiled against the sample database use Rowid. This is the one with the shortest program; the rows that use Rowid are highlighted.

SELECT * FROM artists
addropcodep1p2p3p4p5
0Init0900
1OpenRead02030
2Rewind0800
3Rowid0100
4Column0120
5Column0230
6ResultRow1300
7Next0301
8Halt0000
9Transaction00101
10Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Column, Goto, Halt, Init, Next, OpenRead, ResultRow, Rewind, Transaction.

What the SQLite documentation says

Store in register P2 an integer which is the key of the table entry that P1 is currently point to.

P1 can be either an ordinary table or a virtual table. There used to be a separate OP_VRowid opcode for use with virtual tables, but this one opcode now works for both table types.

From sqlite.org's list of opcodes for SQLite 3.54.1, in the public domain. Opcodes are not a stable interface and change between releases.

← RowData · RowSetAdd →