How to get the last executed SQL statement and bind variable values in oracle

后端 未结 4 1924
感动是毒
感动是毒 2021-02-02 15:21

I have written the following query to get the last executed SQL statement in the oracle database for a particular session. The SQL text does not contain the actual value of the

4条回答
  •  南笙
    南笙 (楼主)
    2021-02-02 16:17

    if you are in sqlplus you can execute

    select * from table ( dbms_xplan.display_cursor (null,null, 'ADVANCED'));

    or if you are looking for SQL executed by someone else just put in their the SQL_ID and child cursor #:

    select * from table ( dbms_xplan.display_cursor ('sql_id',child_cursor#, 'ADVANCED'));

    as in

    select * from table ( dbms_xplan.display_cursor ('a18asdr99x',0, 'ADVANCED'));

    This method shows the only shows peeked bind variables. The only dependable way is tracing with bind variables

    dbms_monitor.session_trace_enable(session_id => 127, serial_num => 29, waits => FALSE, binds => TRUE)

    but of course that has to be done before the query gets executed

提交回复
热议问题