Home > DeveloperSection > Forums > Autoincrement values in column in SQLite database
Steven Hill
Steven Hill

Total Post:10

Points:72
Posted on    November-18-2015 11:00 PM

 SQLite Database  Sqlite 
Ratings:


 1 Reply(s)
 474  View(s)
Rate this:
I want to create a column in SQLite database that takes values(SerialNo or ID) automatically to be unique.
column value I want to start from 0.
How to implement it in database.


Tarun Kumar

Total Post:210

Points:1614
Supported
Posted on    November-20-2015 12:04 AM

Use this- SQLite autoincrement syntax, at the time of table definition:
CREATE TABLE EMPLOYEE(id INTEGER PRIMARY EKY AUTOINCREMENT, name TEXT NOT NULL, age INT NOT NULL);

To insert values into this EMPLOYEE table, use syntax like this:
INSERT INTO EMPLOYEE (name, age) VALUES ('JOHN',25);
Column 'id' will increment its values by autoincrement feature of SQLite database.(by default increment will be from 1, and so on)


Don't want to miss updates? Please click the below button!

Follow MindStick