Sqlite

SQLite AUTOINCREMENT Keyword

SQLite AUTOINCREMENT Keyword

Let’s understand the SQLite AUTOINCREMENT keyword in this tutorial. The SQLite AUTOINCREMENT keyword is used to auto-increment the value of a column in the table.

AUTOINCREMENT Keyword Syntax

We can auto-increment a column value by using the AUTOINCREMENT keyword when creating a table with a specific column name to auto-increment it.

The general syntax for using the AUTOINCREMENT keyword is as follows:

CREATE TABLE IF NOT EXISTS table_name(

column1 <constriants> AUTOINCREMENT,
column2 datatype,
...
columnN datatype,

);

For example:

 

CREATE TABLE IF NOT EXISTS voter (
voterID INTEGER PRIMARY KEY AUTOINCREMENT,
voterName TEXT NOT NULL,
voterAge INTEGER NOT NULL
);

 

 

SQLite Tutorials

SQLite tutorials on this website: