Oracle 查询时报错ORA-00923: FROM keyword not found where expected

Oracle 查询时报错ORA-00923: FROM keyword not found where expected ,从字面上理解就是SQL语法错误缺少FROM关键字,下面简单说一下可能发生报错的几种情况:

第一种
查询语句写的不对,一般是粗心大意写少了FROM关键字或者写多了,

错误示范:

select * dual;
select dummy, from dual;

正确示范:

select dummy from dual;

第二种
查询语句和rownum一起使用时出现

错误示范:

select *,ROWNUM from dual;

正确示范:

select d.*,ROWNUM from dual d;

第三种 2023-02-03补充

查询使用别名时缺少""双引号或误写成单引号''

错误示范:

--数字和特殊字符必须使用双引号
select 'demo' as 1 from dual; 
select 'demo' as 列(column1) from dual;
select 'demo' as 'column1' from dual;

正确示范:

select 'demo' as "1" from dual; 
select 'demo' as "列(column1)" from dual;
select 'demo' as "column1" from dual;
-- 字母和中文或(字母|中文和数字)组合,可以忽略双引号,但是不建议,遇到特殊符号和关键字依旧会出错
select 'demo' as column1 from dual;
select 'demo' as 列1 from dual;

当遇到问题时不要心急,要冷静查看是否语法错误
欢迎大家补充其它出现该报错的情况。

热门相关:首席的独宠新娘   薄先生,情不由己   薄先生,情不由己   照见星星的她   仗剑高歌