SQLite Forum

Best way to handle unique column needs
The sqlite3_last_insert_rowid() function is not useful for querying the highest rowid of a table. First, because it is an attribute of the Connection. If you have not inserted into a rowid table since opening the connection, it will be 0. Second, for the value to have any meaning, you must have exclusive use of this connection, so that no other thread may sneak in and insert into a different table, thus clobbering your value. Third, it only records one rowid; a statement that inserts more than one row will only return the last rowid.