sqliteHow do I use the autoincrement feature in SQLite?
Using the autoincrement feature in SQLite is easy. By including the keyword AUTOINCREMENT after the data type of a column, SQLite will automatically assign a unique integer to that column for each row in the table. For example:
CREATE TABLE test (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT
);
This will create a table with two columns, id and name. The id column will be an integer with a unique value for each row.
Here is an example of inserting a row into the table:
INSERT INTO test (name) VALUES ("John");
The output of this statement will be:
1 row affected
The id column will automatically be incremented to the next unique integer.
Here are some other useful links about using the autoincrement feature in SQLite:
More of Sqlite
- How do I use the SQLite ZIP VFS to compress a database?
- How do I call sqlitepcl.raw.setprovider() when using SQLite?
- How do I use SQLite with Visual Studio?
- How do I use UUIDs in SQLite?
- How do I download and install SQLite zip?
- How do I use the SQLite Workbench?
- How can I adjust the text size in SQLite?
- How do I use SQLite to update or insert data?
- How do I exit SQLite?
- How do I use SQLite transactions?
See more codes...