环境:Oracle Database 11gR2(11.2.0.2) on Linux 故障现象: 执行Group By语句报错ORA-00979。具体的SQL如下:SQLgt; select
环境:Oracle Database 11gR2(11.2.0.2) on Linux
故障现象: 执行Group By语句报错ORA-00979。
具体的SQL如下:
SQL> select a.d1,a.EXIT_type,round(a.cnt1/b.cnt2*100,2) from
2 (select substr(LOGIN_DATE,1,8) d1,EXIT_type,count(*) cnt1 from xxx_connect_log group by substr(LOGIN_DATE,1,8),EXIT_type) a,
3 (select substr(LOGIN_DATE,1,8) d2 ,count(*) cnt2 from xxx_connect_log group by substr(LOGIN_DATE,1,8) ) b
4 where A.d1=B.d2 order by a.d1,a.EXIT_type;
(select substr(LOGIN_DATE,1,8) d2 ,count(*) cnt2 from xxx_connect_log group by substr(LOGIN_DATE,1,8) ) b
*
ERROR at line 3:
ORA-00979: not a GROUP BY expression
这条语句在其他大区的DB上执行均OK,在体验服DB上执行报错。从语法上看,确实是完全没问题的。
碰到这种ORA-报错的情况,我们可以通过设置ErrorStack对错误堆栈进行跟踪,将错误的后台信息比较详尽的转储到跟踪文件,,供分析研究。
ErrorStack的四个级别及说明:
0 Error stack only
1 Error stack and function call stack
2 As level 1 plus the process state
3 As level 2 plus the context area
ErrorStack仅在特定的错误出现的时候才被触发。可以在实例或者会话级别进行设置。
下面我们进行979的ErrorStack跟踪:
SQL> alter system set events='979 trace name errorstack forever,level 3';
System altered.
SQL> select a.d1,a.EXIT_type,round(a.cnt1/b.cnt2*100,2) from
2 (select substr(LOGIN_DATE,1,8) d1,EXIT_type,count(*) cnt1 from xxx_connect_log group by substr(LOGIN_DATE,1,8),EXIT_type) a,
3 (select substr(LOGIN_DATE,1,8) d2 ,count(*) cnt2 from xxx_connect_log group by substr(LOGIN_DATE,1,8) ) b
4 where A.d1=B.d2 order by a.d1,a.EXIT_type;
(select substr(LOGIN_DATE,1,8) d2 ,count(*) cnt2 from xxx_connect_log group by substr(LOGIN_DATE,1,8) ) b
*
ERROR at line 3:
ORA-00979: not a GROUP BY expression
SQL> alter system set events='979 trace name errorstack off';
System altered.
相关阅读:
SPFILE 错误导致数据库无法启动(ORA-01565)
ORA-01172、ORA-01151错误处理
ORA-00600 [2662]错误解决
ORA-01078 和 LRM-00109 报错解决方法
ORA-00471 处理方法笔记