解决方法
CREATE TABLE Student( id INTEGER PRIMARY KEY,first_name TEXT,last_name TEXT );
来自sqlite规范:
One exception to the typelessness of
sqlite is a column whose type is
INTEGER PRIMARY KEY. (And you must use
“INTEGER” not “INT”. A column of type
INT PRIMARY KEY is typeless just like
any other.) INTEGER PRIMARY KEY
columns must contain a 32-bit signed
integer. Any attempt to insert
non-integer data will result in an
error.
http://www.sqlite.org/datatypes.html
您还可以在任意blobish数据上放置主键,例如:
CREATE TABLE Student(id PRIMARY KEY,name)
这有点冒险
INSERT INTO Student(1,"hello") INSERT INTO Student("1","hello")
将导致两行.
如果您需要对其他内容的唯一约束,可以尝试使用Create Index命令