環境: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 處理方法筆記