SQLite VDBE opcode

CreateBtree

Allocate a new b-tree in the main database file if P1==0 or in the TEMP database file if P1==1 or in an attached database if P1>1.

An example

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

CREATE TEMP TABLE scratch (x)
addropcodep1p2p3p4p5
0Init02800
1ReadCookie1320
2If3500
3SetCookie1240
4SetCookie1510
5CreateBtree1210
6OpenWrite01150
7NewRowid0100
8Blob6300
9Insert0318
10Close0000
11Close0000
12Null0450
13Noop2040
14OpenWrite11150
15SeekRowid11710
16Rowid1500
17IsNull52500
18String8060table0
19String8070scratch0
20String8080scratch0
21Copy2900
22String80100CREATE TABLE scratch (x)0
23MakeRecord654BBBDB0
24Insert1450
25SetCookie1110
26ParseSchema100tbl_name='scratch' AND type!='trigger'0
27Halt0000
28Transaction11001
29Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Blob, Close, Copy, Goto, Halt, If, Init, Insert, IsNull, MakeRecord, NewRowid, Noop, Null, OpenWrite, ParseSchema, ReadCookie, Rowid, SeekRowid, SetCookie, String8, Transaction.

What the SQLite documentation says

Allocate a new b-tree in the main database file if P1==0 or in the TEMP database file if P1==1 or in an attached database if P1>1. The P3 argument must be 1 (BTREE_INTKEY) for a rowid table it must be 2 (BTREE_BLOBKEY) for an index or WITHOUT ROWID table. The root page number of the new b-tree is stored in register P2.

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.

← Count · CursorHint →