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 can SQLite and ZFS be used together for software development?
- How can I use an upsert statement to update data in a SQLite database?
- How do I use the SQLite ZIP VFS to compress a database?
- How do I use SQLite with Zephyr?
- How do I use the SQLite zfill function?
- How do I use SQLite transactions?
- How can I use SQLite with Zabbix?
- How do I resolve an error "no such column" when using SQLite?
- How do I use the SQLite SUBSTRING function?
- How do I create a SQLite query using Xamarin?
See more codes...