SQLite Advanced -13.Autoincrement keyword

table of Contents

AUTOINCREMENT is a key field values ​​for the table is automatically incremented. We can use AUTOINCREMENT keyword automatically increase the value of the field on a specific column names when creating tables.

AUTOINCREMENT keyword can only be used for integer (INTEGER) field.

-- 语法
CREATE TABLE table_name (
    column1 INTEGER AUTOINCREMENT;
    column1 datatype;
    ...
);

-- 实例
CREATE TABLE link_men(
    ID INTEGER PRIMARY KEY AUTOINCREMENT;
    NAME TEXT NOT NULL;
    AGE  INT  NOT NULL;
    SALARY REAL;
);

Guess you like

Origin www.cnblogs.com/haitao130v/p/11355047.html