SQLite: autoincrement primary key questions

前端 未结 3 1210
囚心锁ツ
囚心锁ツ 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:28

    Change it to:

    CREATE TABLE Logs ( Id integer PRIMARY KEY,....
    
    0 讨论(0)
  • 2021-01-01 19:29

    I'm not sure whether you're actually using SQLite according to the syntax of your example.

    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 autoincrement.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题