2011-07-06 4 views
2
CREATE TABLE IF NOT EXISTS fw_users (id INT(64) NOT NULL PRIMARY KEY AUTOINCREMENT, auth CHAR(64) UNIQUE, money INT(32) DEFAULT '0', unlocks VARCHAR(8000)) 
내가 그 안에 오류를 볼 수는 없지만, SQLite는 오류가 발생

:이 쿼리에 어떤 문제가 있습니까?

Query failed! AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY 

그것은 이해가되지 않습니다를, ID는

답변

6

INT(64) 충분히 종료되지 않는 정수이고; 그것 이어야합니다 INTEGER이어야합니다.

+0

오, 젠장 SQLite, 고마워! –

3

SQLite 표기법은 INTEGER PRIMARY KEY입니다. Docs reference:

If you declare a column of a table to be INTEGER PRIMARY KEY , then whenever you insert a NULL into that column of the table, the NULL is automatically converted into an integer which is one greater than the largest value of that column over all other rows in the table, or 1 if the table is empty. Or, if the largest existing integer key 9223372036854775807 is in use then an unused key value is chosen at random.
[...]

CREATE TABLE t1(
    a INTEGER PRIMARY KEY, 
    b INTEGER 
);