Sqlite autoincrement select12/8/2023 Now, just use the SQLite last_insert_rowid() function to get the value of the SQLite autoincrement field that was just generated: sqlite> select last_insert_rowid() Next, insert a record into this table, passing a null value into the SQLite autoincrement field: sqlite> INSERT INTO salespeople VALUES (null, 'Fred', 'Flinstone', 10.0) (Note that this field is referred to as an autoincrement field, serial field, or identity column in other databases I have worked with.) Here’s a short, complete example of how this works.įirst, let’s assume we have a SQLite database table defined like this: CREATE TABLE salespeople (Īs you can see, the id field is the PRIMARY KEY field for this SQLite table. How to get the SQLite autoincrement (primary key) value after an insert You can get the integer value of the primary key field from the last insert into an autoincrement field using a SQLite function named last_insert_rowid(), as shown in the example below. So if they get re-added, the hidden field could be set to false and Math would still be at id #1.SQLite autoincrement FAQ: How do I get the autoincrement value from my last SQLite INSERT command? ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |