SQLite VDBE opcode

OpenEphemeral

Open a new cursor P1 to a transient table.

An example

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

SELECT DISTINCT country FROM artists
addropcodep1p2p3p4p5
0Init01100
1OpenEphemeral100k(1,B)8
2OpenRead02030
3Rewind01000
4Column0210
5Found19110
6MakeRecord1120
7IdxInsert121116
8ResultRow1100
9Next0401
10Halt0000
11Transaction00101
12Goto0100

Open it in the EXPLAIN visualizer →

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

What the SQLite documentation says

Open a new cursor P1 to a transient table. The cursor is always opened read/write even if the main database is read-only. The ephemeral table is deleted automatically when the cursor is closed.

If the cursor P1 is already opened on an ephemeral table, the table is cleared (all content is erased).

P2 is the number of columns in the ephemeral table. The cursor points to a BTree table if P4==0 and to a BTree index if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure that defines the format of keys in the index.

The P5 parameter can be a mask of the BTREE_* flags defined in btree.h. These flags control aspects of the operation of the btree. The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are added automatically.

If P3 is positive, then reg[P3] is modified slightly so that it can be used as zero-length data for Insert. This is an optimization that avoids an extra Blob opcode to initialize that register.

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.

← OpenDup · OpenPseudo →