The PRIMARY KEY attribute normally creates a UNIQUE index on the column or columns that are specified as the PRIMARY KEY. The only exception to this behavior is special INTEGER PRIMARY KEY column, described below. According to the SQL standard, PRIMARY KEY should imply NOT NULL. Unfortunately, due to a long-standing coding oversight, this is not the case in SQLite. SQLite allows NULL values in a PRIMARY KEY column. We could change SQLite to conform to the standard (and we might do so in the future), but by the time the oversight was discovered, SQLite was in such wide use that we feared breaking legacy code if we fixed the problem. So for now we have chosen to continue allowing NULLs in PRIMARY KEY columns. Developers should be aware, however, that we may change SQLite to conform to the SQL standard in future and should design new programs accordingly.
上面就是结果
我看了下好像
id int primary key
的时候能自己生成索引
id integer primary key autoincrement
id integer primary key
这两种方式不自己生成索引
id int primary key autoincrement 提示错误,int时不能用 autoincrement
sqlite> create table xxx (id int primary key,col int);
sqlite> select * from SQLITE_MASTER;
table|xxx|xxx|10|CREATE TABLE xxx (id int primary key,col int) index|sqlite_autoindex_xxx_1|xxx|11|
sqlite>