NewRowid
Get a new integer record number (a.k.a "rowid") used as the key to a table.
An example
26 of the 178 statements we compiled against the sample database use NewRowid. This is the one with the shortest program; the rows that use NewRowid are highlighted.
CREATE TRIGGER t1 AFTER INSERT ON artists BEGIN SELECT 1; END
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 13 | 0 | 0 | |
| 1 | OpenWrite | 0 | 1 | 0 | 5 | 0 |
| 2 | String8 | 0 | 2 | 0 | trigger | 0 |
| 3 | String8 | 0 | 3 | 0 | t1 | 0 |
| 4 | String8 | 0 | 4 | 0 | artists | 0 |
| 5 | Integer | 0 | 5 | 0 | 0 | |
| 6 | String8 | 0 | 6 | 0 | CREATE TRIGGER t1 AFTER INSERT ON artists BEGIN SELECT 1; END | 0 |
| 7 | NewRowid | 0 | 1 | 0 | 0 | |
| 8 | MakeRecord | 2 | 5 | 7 | BBBDB | 0 |
| 9 | Insert | 0 | 7 | 1 | 24 | |
| 10 | SetCookie | 0 | 1 | 2 | 0 | |
| 11 | ParseSchema | 0 | 0 | 0 | type='trigger' AND name='t1' | 0 |
| 12 | Halt | 0 | 0 | 0 | 0 | |
| 13 | Transaction | 0 | 1 | 1 | 0 | 1 |
| 14 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: Goto, Halt, Init, Insert, Integer, MakeRecord, OpenWrite, ParseSchema, SetCookie, String8, Transaction.
What the SQLite documentation says
Get a new integer record number (a.k.a "rowid") used as the key to a table. The record number is not previously used as a key in the database table that cursor P1 points to. The new record number is written written to register P2.
If P3>0 then P3 is a register in the root frame of this VDBE that holds the largest previously generated record number. No new record numbers are allowed to be less than this value. When this value reaches its maximum, an SQLITE_FULL error is generated. The P3 register is updated with the ' generated record number. This P3 mechanism is used to help implement the AUTOINCREMENT feature.
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.