SQLite AUTOINCREMENT is a keyword used to automatically increment a field in a table. We can automatically increase the value of a field using the AUTOINCREMENT keyword when creating a table with a specific column name to automatically increase it.
The AUTOINCREMENT keyword can only be used with the INTEGER field. Syntax:
The main use of the AUTOINCREMENT keyword is as follows:
CREATE TABLE table_name (column1 INTEGER AUTOINCREMENT, column2 data type, column3, ..... columnN data type,);
See the example below: Consider the COMPANY table, which will be created as follows:
sqlite> CREATE TABLE TB_COMPANY_INFO (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INT NOT NULL, CHAR (50), SALARY REAL);
Now paste the following entries into table TB_COMPANY_INFO:
INSERT INTO TB_COMPANY_INFO (NAME, AGE, ADDRESS, DISPLAY) VALUES ('MANOJ KUMAR', 40, 'Meerut, UP, INDIA', 200000.00);
Now select the entry SELECT * FROM TB_COMPANY_INFO TITLE ID NAME ADDRESS 1 Manoi Kumar 40 Meerut, UP, INDIA 200000.00
mkumar0304 May 22 '17 at 11:13 2017-05-22 11:13
source share