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 can I use the XOR operator in a SQLite query?
- How do I troubleshoot a near syntax error when using SQLite?
- How do I import data from a SQLite zip file?
- How do I use SQLite VACUUM to reclaim disk space?
- How do I use the SQLite VARCHAR data type?
- How do I exit SQLite?
- How do I download and install SQLite zip?
- How do I extract the year from a datetime value in SQLite?
See more codes...