AUTOINCREMENT VALUES IN COLUMN IN SQLITE DATABASE

Steven Hill

Total Post:10

Points:72
Posted by  Steven Hill
 1023  View(s)
Ratings:
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.
  1. Tarun Kumar

    Post:214

    Points:1642
    Re: Autoincrement values in column in SQLite database

    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)

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!