H2 'AS' 列别名错误

H2 'AS' Column alias error

所以这是 H2 table 架构:

drop table IF EXISTS

CREATE TABLE CAR_SPEED
(
  ACC_RATE                      VARCHAR2(20) NOT NULL,
  SPEED_GROUP                   VARCHAR2(30) NOT NULL,
  MAX_SPEED                     NUMBER,
  MIN_SPEED                     NUMBER       
);

我尝试执行的查询语句是这样的:

SELECT distinct MAX_SPEED as limit
FROM CAR_SPEED  
WHERE ACC_RATE ='Full' 
AND SPEED_GROUP = 'CS';

当我在 oracle 中 运行 这个完全相同的查询时我没有任何问题但是当我在 h2 上 运行 我得到以下错误

Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "SELECT DISTINCT MAX_SPEED AS LIMIT[*]
FROM CAR_SPEED 
WHERE CAR_SPEED 
AND SPEED_GROUP = 'CS' "; expected "identifier"; SQL statement:
SELECT DISTINCT MAX_SPEED AS LIMIT[*]
FROM CAR_SPEED 
WHERE CAR_SPEED 
AND SPEED_GROUP = 'CS' [42001-160]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)

如果我从查询中删除 'AS LIMIT' 它将 运行 正常,但是当我保留它时,它会给我这个语法错误。有人知道为什么吗?

limit 是一个 reserved word。使用另一个或用双引号将其转义。