SQLite VDBE opcode

OpenWrite

Open a read/write cursor named P1 on the table or index whose root page is P2 (or whose root page is held in register P2 if the OPFLAG_P2ISREG bit is set in P5 - see below).

An example

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

DELETE FROM genres WHERE name < ?
addropcodep1p2p3p4p5
0Init01200
1Noop2100
2OpenWrite190k(1,)0
3Rewind111200
4Variable1200
5IsNull21100
6Affinity210B0
7IdxGE111210
8Column1010
9Delete110genres2
10Next1700
11Halt0000
12Transaction01101
13Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Affinity, Column, Delete, Goto, Halt, IdxGE, Init, IsNull, Next, Noop, Rewind, Transaction, Variable.

What the SQLite documentation says

Open a read/write cursor named P1 on the table or index whose root page is P2 (or whose root page is held in register P2 if the OPFLAG_P2ISREG bit is set in P5 - see below).

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.

Allowed P5 bits:

This instruction works like OpenRead except that it opens the cursor in read/write mode.

See also: OpenRead, 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.

← OpenRead · Or →