Definitions and examples see: http://www.runoob.com/sqlite/sqlite-autoincrement.html
Sqliteautoincrement (auto increment)
SQLite's autoincrement is a keyword that is used to automatically increment the value of a field in a table. We can use the autoincrement keyword on a specific column name to automatically increase the value of the field when we create the table.
The keyword autoincrement can only be used for integer fields.
Instance
Let's say the company table you want to create looks like this:
SQLite> CREATE TABLE company( ID INTEGER PRIMARY KEY autoincrement, NAME TEXT not Null, age int. not NULL, ADDRESS CHAR, SALARY REAL);
Now, insert the following records into the company table:
INSERT into Company(NAME,Age,ADDRESS,SALARY)VALUES( ' Paul ', 32, ' California ', 20000.00 );INSERT into Company(NAME,Age,ADDRESS,SALARY)VALUES(' Allen ', 25, ' Texas ', 15000.00 );INSERT into Company(NAME,Age,ADDRESS,SALARY)VALUES(' Teddy ', 23, ' Norway ', 20000.00 );INSERT into Company(NAME,Age,ADDRESS,SALARY)VALUES( ' Mark ', 25, ' Rich-mond ', 65000.00 );INSERT into Company(NAME,Age,ADDRESS,SALARY)VALUES( ' David ', 27, ' Texas ', 85000.00 );INSERT into Company(NAME,Age,ADDRESS,SALARY)VALUES( ' Kim ', 22, ' South-hall ' , 45000.00 INSERT into company (name,age ,address,salary) Span class= "PLN" >values ( ' James ' , 24, ' Houston ' , 10000.00
This inserts 7 tuples into the company table, at which time the records for the company table are as follows:
ID NAME Age ADDRESS SALARY---------- ---------- ---------- ---------- ----------1 Paul 32 California 20000.02 Allen 25 Texas 15000.03 Teddy 23 Norway 20000.04 Mark 25 Rich-mond 65000.05 david 27 texas 85000.06 kim 22 Span class= "Typ" >south-hall 45000.07 james 24 houston 10000.0
[Qt][sql]sql Learning record 5_sqlite autoincrement (auto increment)