在 alert 日志中出现如下报错:
2023-10-16T15:34:50.567922+08:00
WARNING: too many parse errors, count=659874 SQL hash=0xbbcb647d
PARSE ERROR: ospid=16825, error=923 for statement:
Additional information: hd=0x16b1e3d08 phd=0x16b1e5130 flg=0x28 cisid=113 sid=113 ciuid=113 uid=113 sqlid=0y30pf6xwqt3x
...Current username=【USERNAME】
...Application: JDBC Thin Client Action:
2023-10-16T15:35:05.726916+08:00
WARNING: too many parse errors, count=113 SQL hash=0x50dafd2e
PARSE ERROR: ospid=12785, error=942 for statement:
Additional information: hd=0x12fc68a68 phd=0x12d29d8c0 flg=0x28 cisid=110 sid=110 ciuid=110 uid=110 sqlid=c4fpp9j8dpz9f
...Current username=【USERNAME】
2023-10-20T12:50:00.550077+08:00
PARSE ERROR: ospid=38140, error=942 for statement:
Additional information: hd=0x725117e0 phd=0x71ed5908 flg=0x20 cisid=110 sid=110 ciuid=110 uid=110 sqlid=gjpqak7mpu67n
...Current username=【USERNAME】
...Application: JDBC Thin Client Action:
2023-10-20T13:00:04.073377+08:00
ALTER SYSTEM ARCHIVE LOG
2026-07-23T17:31:47.863199+08:00
WARNING: too many parse errors, count=23600 SQL hash=0x6b3e034c
PARSE ERROR: ospid=10603, error=904 for statement:
2026-07-23T17:31:47.863346+08:00
SELECT NOW() FROM DUAL <---- 在日志中可能看得到 SQL 语句
Additional information: hd=0x1ade6d9d8 phd=0x383afd418 flg=0x20 cisid=116 sid=116 ciuid=116 uid=116 sqlid=guwftzjpmw0uc
...Current username=【USERNAME】
...Application: JDBC Thin Client Action:这是12.2的新特性,在之前的版本中,如果出现解析错误,需要在数据库中设置 10035 EVENT,设置后,就会向 alert 日志中写入解析错误的详细信息。
这些信息里可能会输出SQL语句,也可能不会,前后多看看。
从12.2开始,不论是否设置 10035 事件,当出现解析错误且达到阈值的时候(100,由隐藏参数 _kks_parse_error_warning 决定),都会向 alert 日志中输出告警信息。
如上所示,信息中给出了 SQL hash 或 sqlid,但是,由于是 PARSE ERROR,无法在 SQL 相关视图中通过 SQL_ID 查询到相关 SQL。
SQL> col KGLNAOBJ for a40;
SQL> col KGLOBTS0 for a20;
SQL> set lines 200;
SQL> select KGLNAOBJ,KGLOBTS0,KGLNAHSH,KGLNAHSV from X$KGLOB where KGLOBT03='0y30pf6xwqt3x'; (SQL ID)
或者
SQL> select KGLNAOBJ,KGLOBTS0,KGLNAHSH,KGLNAHSV from X$KGLOB where KGLNAHSV like '%bbcb647d'; (SQL hash)
KGLNAOBJ KGLOBTS0 KGLNAHSH KGLNAHSV
--------------------------- -------------------- ---------- --------------------------------
select 1 JDBC Thin Client 3150668925 eae8b8ed4f6c136a0f0c1571bbcb647d
select 1 JDBC Thin Client 3150668925 eae8b8ed4f6c136a0f0c1571bbcb647d这样一来,我们就定位到了 SQL 语句(第一列的 KGLNAOBJ)。
如果报错信息中的 OSPID 不变的话,我们还可以通过 OSPID 定位到 SID,进一步定位到 MACHINE,MODULE 和 PROGRAM。
也可以通过 oerr 命令来查看报错的具体问题:
[xoracle@oa-db01 ~]$ oerr ora 923
00923, 00000, "FROM keyword not found where expected"
// *Cause: In a SELECT or REVOKE statement, the keyword FROM was
// either missing, misplaced, or misspelled. The keyword FROM
// must follow the last selected item in a SELECT statement or
// the privileges in a REVOKE statement.
// *Action: Correct the syntax. Insert the keyword FROM where
// appropriate. The SELECT list itself also may be in error. If
// quotation marks were used in an alias, check that double
// quotation marks enclose the alias. Also, check to see if a
// reserved word was used as an alias.
[xoracle@oa-db01 ~]$