SQLiteException:近"引用":语法错误语法错误、SQLiteException、QUOT

2023-09-07 23:20:26 作者:冷都男 i

String CREATE_ASSIGNMENTS_TABLE= "create table "
        + ASSIGNMENTS + "(" + TITLE
        + " text not null, " + DESCRIPTION
        + " text not null, " + REFERENCES + " text not null );";

这是我创建表查询到SQLite中创建一个表。

This is my create table query to create a table in SQLite.

我有三个字段(标题,描述,参照)。所有的文本字段。但是,当我执行code,我得到了以下异常:

I have three fields (title,description,reference). All are text fields. But when I execute the code, I get the following Exception:

android.database.sqlite.SQLiteException: near "references": syntax error (code 1): , while compiling: create table ASSIGNMENTS(TITLE text not null, DESCRIPTION text not null, REFERENCES text not null);

这是指向一个错误的参考字段。但我无法找到任何语法的错误。请帮我在这件事情。

It is pointing to an error in the REFERENCES field. But I couldn't find any syntax error there. Please help me out in this matter.

推荐答案

参考是的关键字在SQL语法。要么更改列名或引用它的反引号:

REFERENCES is a keyword in SQL syntax. Either change the column name or quote it in backticks:

`REFERENCES`