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 extract the year from a datetime value in SQLite?
- How do I use SQLite with Maven?
- How do I use the SQLite ZIP VFS to compress a database?
- How do I set up an ODBC driver to connect to an SQLite database?
- How do I use SQLite with QML?
- How do I troubleshoot a near syntax error when using SQLite?
- How can SQLite and ZFS be used together for software development?
- How do I use SQLite with Zephyr?
- How can I use SQLite with Zabbix?
- How can I write SQLite queries?
See more codes...