Android SQLite 表名可以是 'TABLE'

Android SQLite can a tables name be 'TABLE'

我正在为 SQLite 使用 GreenDAO ORM,我面临的问题是我有一个名为 [=24= 的 table ]TABLE,我使用下面的命令来创建table:

db.execSQL("CREATE TABLE 'TABLE' (" + //
                "'_id' INTEGER PRIMARY KEY ," + // 0: id
                "'TYPE' INTEGER NOT NULL ," + // 1: Type
                "'NAME' TEXT NOT NULL ," + // 2: Name
                "'NUMBER' INTEGER NOT NULL ," + // 3: Number
                "'CHAIRS' INTEGER NOT NULL ," + // 4: Chairs
                "'NOTE' TEXT NOT NULL ," + // 5: Note
                "'PRIORITY' INTEGER NOT NULL ," + // 6: Priority
                "'STATUS' INTEGER NOT NULL ," + // 7: Status
                "'ID_RELATED_RECORD' INTEGER NOT NULL ," + // 8: idRelatedRecord
                "'REGISTERED_ON' INTEGER NOT NULL ," + // 9: RegisteredOn
                "'REGISTERED_BY' TEXT NOT NULL ," + // 10: RegisteredBy
                "'ID_TICKET_CATEGORY' INTEGER NOT NULL ," + // 11: idTicketCategory
                "'ID_SEAT_MAP' INTEGER NOT NULL );"); // 12: idSeatMap

这通过创建 table 按应有的方式工作,但是当我尝试 select 所有数据时:

daoSession.getTableDao().queryBuilder().list();

这会引发异常:

android.database.sqlite.SQLiteException: near "TABLE": syntax error 
(code 1): , while compiling: 
SELECT T.'_id', T.'TYPE',T.'NAME', T.'NUMBER',T.'CHAIRS', T.'NOTE', T.'PRIORITY', T.'STATUS', T.'ID_RELATED_RECORD', T.'REGISTERED_ON',T.'REGISTERED_BY', T.'ID_TICKET_CATEGORY', T.'ID_SEAT_MAP' 
FROM TABLE T

我认为问题是 Table 被命名为 'TABLE' 但我不太确定?

尝试使用逗号:``,而不是:' '

不,你不能命名 table TABLE,这是一个关键字。

sqlite 关键字列表:https://www.sqlite.org/lang_keywords.html