SQLite: autoincrement primary key questions

前端 未结 3 1270
囚心锁ツ
囚心锁ツ 2021-01-01 18:45

I have the following SQLite query:

CREATE TABLE Logs ( Id integer IDENTITY (1, 1) not null CONSTRAINT PKLogId PRIMARY KEY, ...
3条回答
  •  不知归路
    2021-01-01 19:30

    If you are, you may be interested in SQLite FAQ #1: How do I create an AUTOINCREMENT field?:

    Short answer: A column declared INTEGER PRIMARY KEY will auto increment.

    This in fact is not entirely accurate. An integer primary key will indeed increment, however if the table drops all rows, it starts from the beginning again, It is important if you want to have all associated records tied correctly to use the autoincrement description after the primary key declaration on the integer field.

提交回复
热议问题