SQLite VDBE opcode

OpenRead

Open a read-only cursor for the database table whose root page is P2 in a database file.

An example

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

SELECT count(*) FROM tracks
addropcodep1p2p3p4p5
0Init0700
1OpenRead1190k(2,,)0
2Count1100
3Close1000
4Copy1200
5ResultRow2100
6Halt0000
7Transaction00101
8Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Close, Copy, Count, Goto, Halt, Init, ResultRow, Transaction.

What the SQLite documentation says

Open a read-only cursor for the database table whose root page is P2 in a database file. The database file is determined by P3. P3==0 means the main database, P3==1 means the database used for temporary tables, and P3>1 means used the corresponding attached database. Give the new cursor an identifier of P1. The P1 values need not be contiguous but all P1 values should be small integers. It is an error for P1 to be negative.

Allowed P5 bits:

The P4 value may be either an integer (P4_INT32) or a pointer to a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo object, then table being opened must be an index b-tree where the KeyInfo object defines the content and collating sequence of that index b-tree. Otherwise, if P4 is an integer value, then the table being opened must be a table b-tree with a number of columns no less than the value of P4.

See also: OpenWrite, ReopenIdx

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.

← OpenPseudo · OpenWrite →