不能对名称为 "when" 的列类型时间戳应用 where 子句

can not apply where clause on column type timestamp whose name is "when"

我有一个 table,其列是 id(integer), emp_name(varchar2), when(timestamp)。我想在名为 WHEN 的列上应用 where 子句。我正在尝试执行查询

select * from attendant where WHEN > 2016-04-28 10:05:30.0000;

但它给我错误。

我很确定 WHEN 是保留关键字,因此您必须将其转义。此外,您必须将日期时间值放入 '':

select * 
from attendant 
where "WHEN" > '2016-04-28 10:05:30.0000';

因为whencase语句中使用的保留关键字。
您可以像这样更改您的查询

select * 
from attendant 
where `WHEN` > '2016-04-28 10:05:30.0000';

即使用 tick ( ` ) 来引用时间。

select * 
from attendant 
where attendant.WHEN > '2016-04-28 10:05:30.0000';

即点符号。