查看当前oracle中正在执行的sql语句

先执行以下查询语句

select a.program, b.spid, c.sql_text,c.SQL_ID
  from v$session a, v$process b, v$sqlarea c
 where a.paddr = b.addr
   and a.sql_hash_value = c.hash_value
   and a.username is not null;
PROGRAM                         SPID    SQL_TEXT                  SQL_ID
---------------------------------------------------------------- -------------
racgimon@cdcj1 (TNS V1-V3)      12      DECLARE     reason_id    65vuzhm491wk9
oracleRLZY@rx6600-2 (TNS V1-V3) 25867   SELECT "AKB020" FROM "KB 09rp36jmgpj5a
oracleRLZY@rx6600-2 (TNS V1-V3) 25869   SELECT "AAC001","BTC102" 00931052n13uq
oracleRLZY@rx6600-2 (TNS V1-V3) 3018    SELECT "AAC001","BTC102" 00931052n13uq
plsqldev.exe                    26531   select a.program, b.spid 5qq47bz3tzfws
JDBC Thin Client                21074   select * from ( select r 686nqabc8sgs2

如上图中的program列中的jdbc thin client代表的是通过jdbc连接执行的sql语句,由于sql_text列没有显示完整
的sql语句.所以找到sql_id:686nqabc8sgs2再查询v$sql

select a.* from v$sql a where a.SQL_ID='686nqabc8sgs2'

可以查看完整的sql文本内容

发表评论

电子邮件地址不会被公开。