1

我使用 Access 数据库编写了一个 java 程序,我可以记录字符串值,但是我使用数字字段列为数字值编写的查询会生成一个 INSERT INTO 错误。以下是查询和错误。

Level - Col in table with number field

Access Insert Statement:
INSERT INTO SystemEquipment(Level) Values (12);

Error:
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

**Tried to run the query with and without single quotes and semicolons
4

1 回答 1

4

因为LEVEL是保留关键字。您必须使用[]

INSERT INTO SystemEquipment([Level]) Values (12);

来自 MS Access Docs,

如果保留字已被使用,您可以通过用括号 ([]) 将每个出现的字括起来来避免错误消息。但是,最好的解决方案是将名称更改为非保留字。

于 2013-03-12T15:40:31.137 回答