繁体   English   中英

使用HSQLDB关键字的奇怪行为

[英]Strange behavior by using the keyword of HSQLDB

在HSQLDB中创建新表时,我得到一个奇怪的结果。 从HSQLDB的文档中,“用户”是一个关键字,通常,除非表名或列名用双引号括起来,否则我们不能使用该值。

但是,我可以创建一个数据库名称为“ USER”的数据库表和一个数据库名称为“ user”的数据库表DATA_RESULT,而无需双引号。

从数据库读取数据时发生问题。 例如,当我执行以下命令时: "select * from DATA_RESULT"并从ResultSet中读取“ user”的值,则它起作用。

如果我执行"select user from DATA_RESULT""SELECT * from DATA_RESULT where user = 1" ,则会发生错误。 sql语句执行不正确,ResultSet.next()始终返回false。

此外,从HSQLDB的关键字列表中可以看出HyperSQL has two modes of operation, which are selected with the SET DATABASE SQL NAMES { TRUE | FALSE } to allow or disallow the keywords as identifiers. The default mode is FALSE and allows the use of most keywords as identifiers HyperSQL has two modes of operation, which are selected with the SET DATABASE SQL NAMES { TRUE | FALSE } to allow or disallow the keywords as identifiers. The default mode is FALSE and allows the use of most keywords as identifiers HyperSQL has two modes of operation, which are selected with the SET DATABASE SQL NAMES { TRUE | FALSE } to allow or disallow the keywords as identifiers. The default mode is FALSE and allows the use of most keywords as identifiers ,但没有说明是否可以将“ user”用作标识符。

我正在使用HSQLDB 2.0.0。

这很令人困惑。 有人知道这是怎么回事吗?

提前致谢! 任何建议都会有所帮助。

USER是获取当前用户名称的功能。 例如:

CALL USER

您当然可以使用USER作为表名或列名。

在SELECT语句中,在名称周围使用双引号。

CREATE TABLE DATA_RESULT ("USER" INT, DATA VARCHAR(100))
SELECT * FROM DATA_RESULT WHERE "USER" = 1

使用双引号时,大小写必须匹配。

请注意,网站上的《指南》会定期更新,并且当前对应于最新版本2.2.5。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM