SQLite CREATE查询出错

时间:2013-10-01 12:25:47

标签: sqlite syntax-error create-table

一个愚蠢的问题,但我在这里找不到错误......

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 个答案:

答案 0 :(得分: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)
)