Difference between INT PRIMARY KEY and INTEGER PRIMARY KEY SQLite

后端 未结 3 1525
醉酒成梦
醉酒成梦 2020-12-13 09:08

Is there any difference between INT PRIMARY KEY and INTEGER PRIMARY KEY when defining a schema for a table? When int primary key is used, I got

3条回答
  •  臣服心动
    2020-12-13 09:57

    Just to add albeit implied already on the answers here. The INTEGER PRIMARY KEY column that you created is simply an alias for ROWID or _ROWID_ or OID. And if the AUTOINCREMENT keyword is added then every new record inserted is an increment of 1 of the last ROWID and the last ROWID is kept by an sqlite internal table named sqlite_sequence.

    See link here and here

    On the other hand if you declare a column as INT PRIMARY KEY sqlite create an automatic index (hence the sqlite_autoindex) to keep track of the value inserted in the primary key to make sure it is unique.

提交回复
热议问题