SQLiteSimple answer: A field declared as an INTEGER PRIMARY KEY is automatically incremented.
Here is the detailed answer: starting with the 2.3.4 version of SQLite, if you declare a field in a table to be an INTEGER PRIMARY KEY, then whenever you insert a null value into that field of the table, the null value is automatically replaced with the most An integer that has a large value of 1, and if the table is empty, it is replaced with 1. For example, suppose you have a data sheet like this:
CREATE TABLE T1 (
A INTEGER PRIMARY KEY,
b INTEGER
);
In this data table, declare
INSERT into T1 VALUES (null,123);
In a logical sense equivalent to:
INSERT into T1 VALUES ((SELECT Max (a) from T1) +1,123);
A new API function Sqlite3_last_insert_rowid () returns the Shaping key for the most recent insert operation
Note that this integer key is always 1 larger than the last key in the previously inserted table. The new key is unique relative to the existing key in the table, but it may overlap with the key values that were previously removed from the table. To always get the key that is unique throughout the table, add the keyword AutoIncrement before the declaration of the integer PRIMARY key. The selected key will always be 1 larger than the largest key already present in the table. If the maximum possible key already exists in the table, the insert operation fails and returns a sqlite_full error code.
How to create a self-increment field in SQLite