Sqlite管理器语法错误



嗨,我正在使用下面的代码在sqlite管理器上生成一个表。

CREATE TABLE Transaction (ID PRIMARY KEY , amount REAL , currencyCode CHAR(3) , comments VARCHAR , debitAccount INTEGER , creditAccount INTEGER , debitAccountExchangeRate REAL , creditAccountExchangeRate REAL , FOREIGN KEY (currencyCode)REFERENCES Currency (code) , FOREIGN KEY (debitAccount) REFERENCES Account  (ID) , FOREIGN KEY (parentAccount) REFERENCES Account (ID ));

,但我得到语法错误。谁能指出我在这里做错了什么?

    [ near "Transaction": syntax error ]
    Exception Name: NS_ERROR_FAILURE
      Exception Message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)      [mozIStorageConnection.createStatement]

试试这个…

CREATE TABLE "Transaction" (ID PRIMARY KEY , amount REAL , currencyCode CHAR(3) , comments VARCHAR , debitAccount INTEGER , creditAccount INTEGER , debitAccountExchangeRate REAL , creditAccountExchangeRate REAL , FOREIGN KEY (currencyCode)REFERENCES Currency (code) , FOREIGN KEY (debitAccount) REFERENCES Account  (ID) , FOREIGN KEY (creditAccount) REFERENCES Account (ID ));

我有一个类似的问题,信不信由你,只是改变我的表名为"TRANSACTIONS"为我工作。"Transaction"在SQLite中必须是一个保留字,但我知道我得到的错误信息是远远没有帮助的。

希望对你有帮助。

我得到了这个错误,因为我忘记用逗号分隔查询中的列。我想它不像那样。

I was doing:

SELECT Col1 Col2 Col3 FROM Table1

SQLite was expected:

Select Col1, Col2, Col3 FROM Table1

相关内容

  • 没有找到相关文章

最新更新