SQLite AUTOINCREMENT is a keyword used for auto incrementing a value of a field in the table. We can auto increment a field value by using AUTOINCREMENT keyword when creating a table with specific column name to auto increment.

The keyword AUTOINCREMENT can be used with INTEGER field only.

Syntax

The basic usage of AUTOINCREMENT keyword is as follows −

CREATE TABLE table_name(
   column1 INTEGER AUTOINCREMENT,
   column2 datatype,
   column3 datatype,
   .....
   columnN datatype,
);

Example

Consider COMPANY table to be created as follows −

sqlite> CREATE TABLE COMPANY(
   ID INTEGER PRIMARY KEY AUTOINCREMENT,
   NAME           TEXT      NOT NULL,
   AGE            INT       NOT NULL,
   ADDRESS        CHAR(50),
   SALARY         REAL
);


출처: https://www.tutorialspoint.com/sqlite/sqlite_using_autoincrement.htm

'SQL > SQLITE' 카테고리의 다른 글

sqlite using autoincrement  (0) 2017.08.14

+ Recent posts