You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ORA-00905缺失关键字报错:请帮忙修正指定SQL语句错误

ORA-00905: missing keyword错误修正

原执行报错的SQL语句:

select employee_id,case first_name when first_name = "Steve" then "My name is Steve" 
                        else first_name
end
from hr.employees
where 
employee_id = 150;

修正后的正确SQL语句

写法一:匹配值形式的CASE表达式

select employee_id,
       case first_name 
           when 'Steve' then 'My name is Steve' 
           else first_name
       end
from hr.employees
where employee_id = 150;

写法二:条件判断形式的CASE表达式

select employee_id,
       case 
           when first_name = 'Steve' then 'My name is Steve' 
           else first_name
       end
from hr.employees
where employee_id = 150;

错误原因

  • 使用case first_name when语法时,when后应直接跟匹配值,不能写first_name = "Steve"这类条件表达式
  • Oracle中字符串常量必须用单引号包裹,双引号仅用于标识符(比如特殊命名的列名、表名)

内容的提问来源于stack exchange,提问作者Saketh Patchava

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 11:47:02