note 62216 deleted from function.sqlite-last-insert-rowid by cmb
| From: | cmb@php.net | Date: | Mon, 02 Nov 2020 15:00:58 +0000 |
| Subject: | note 62216 deleted from function.sqlite-last-insert-rowid by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215741@lists.php.net to get a copy of this message | ||
Note Submitter:
----
Note that you don't need to create a primary key for your table. In the absence of an integer
primary key, SQLite simply uses an internal key called "RowID" or "OID".
It has all of the features of a normal integer primary key(auto-incrementing, returned by
sqlite_last_insert_rowid(), accessible via SELECT, etc), except that it's handled better by
SQLite and doesn't require the extra characters in the "CREATE" command.
If you just want a primary key as an auto-incrementing ID for your rows, save yourself the trouble
and just use "OID" instead.
Also, according to the SQLite website, the id returned is for the last insert in the current
*connection*, not just database. This means that if there are two connections to the same database
at the same time, and both perform "INSERT", each can get it's own inserted rowid
later, so basically this is thread-safe(So long as no-one calls "REINDEX").