It is documented to start at 1:

<http://www.sqlite.org/autoinc.html>

If a table contains a column of type INTEGER PRIMARY KEY, then that column becomes an alias for the ROWID.

[...]

If no ROWID is specified on the insert, an appropriate ROWID is created automatically. The usual algorithm is to give the newly created row a ROWID that is one larger than the largest ROWID in the table prior to the insert. If the table is initially empty, then a ROWID of 1 is used. If the largest ROWID is equal to the largest possible integer (9223372036854775807 in SQLite version 3.0 and later) then the database engine starts picking candidate ROWIDs at random until it finds one that is not previously used.

--Steve

On Feb 2, 2005, at 11:25 AM, Andrew Shakinovsky wrote:

Will the default value of an INTEGER PRIMARY KEY column always start at
1?
Example:
CREATE TABLE xyz (id INTEGER PRIMARY KEY);
INSERT INTO xyz VALUES (NULL);

Will the value of the id column always be 1 in this example? I tried
numerous tests, and it seems to always start at 1, I wanted to just make
sure this would always be the case before I start relying on it in my
code.

Reply via email to