2013-10-01 84 views
0

一個愚蠢的問題,但我不能在這裏找到一個錯誤...錯誤SQLite中創建查詢

CREATE TABLE units (_id INTEGER PRIMARY KEY AUTOINCREMENT, group_id INTEGER NOT NULL, unit_name STRING NOT NULL UNIQUE (group_id, unit_name)) 

SQLite的說:

SQLiteManager: Likely SQL syntax error: CREATE TABLE units (_id INTEGER PRIMARY KEY AUTOINCREMENT, group_id INTEGER NOT NULL, unit_name STRING NOT NULL UNIQUE (group_id, unit_name)) 
[ near "(": syntax error ] 
Exception Name: NS_ERROR_FAILURE 
Exception Message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [mozIStorageConnection.createStatement] 

什麼錯誤?

回答

1

我的猜測是缺少逗號UNIQUE前:

CREATE TABLE units (
    _id INTEGER PRIMARY KEY AUTOINCREMENT, 
    group_id INTEGER NOT NULL, 
    unit_name STRING NOT NULL, 
    UNIQUE (group_id, unit_name) 
) 
+0

是的,這是正確的。謝謝! – Prizoff