通过v$sql_bind_capture 获取绑定变量
SQL> connect sys/oracle@mytest172.16.14.29 as sysdba
已连接。
SQL> variable o varchar2(30)
SQL> exec :o :='SYS'
PL/SQL 过程已成功完成。
SQL> select * from v$mystat;
SID STATISTIC# VALUE
---------- ---------- ----------
309 0 1
SQL> select * from test where USERNAME = :o;
另外开启一个会话
SQL> select PREV_SQL_ID from v$session where sid='309';
PREV_SQL_ID
-------------
7awrh0xv2dvfn
SQL> select value_string from v$sql_bind_capture where sql_id='7awrh0xv2dvfn';
VALUE_STRING
--------------------------------------------------------------------------------
SYS
The bind variable contents are refreshed in V$SQL_BIND_CAPTURE at the earliest every 15 minutes. If you require a faster refresh for analysis purposes, you can temporarily set the underlying underscore parameter _CURSOR_BIND_CAPTURE_INTERVAL to a value lower than 900 seconds (-> the default 15 minutes) as follows:
ALTER SYSTEM SET "_CURSOR_BIND_CAPTURE_INTERVAL"=<seconds>;
转自:http://blog.itpub.net/7728585/viewspace-719037/
SQL> connect sys/oracle@mytest172.16.14.29 as sysdba
已连接。
SQL> variable o varchar2(30)
SQL> exec :o :='SYS'
PL/SQL 过程已成功完成。
SQL> select * from v$mystat;
SID STATISTIC# VALUE
---------- ---------- ----------
309 0 1
SQL> select * from test where USERNAME = :o;
另外开启一个会话
SQL> select PREV_SQL_ID from v$session where sid='309';
PREV_SQL_ID
-------------
7awrh0xv2dvfn
SQL> select value_string from v$sql_bind_capture where sql_id='7awrh0xv2dvfn';
VALUE_STRING
--------------------------------------------------------------------------------
SYS
The bind variable contents are refreshed in V$SQL_BIND_CAPTURE at the earliest every 15 minutes. If you require a faster refresh for analysis purposes, you can temporarily set the underlying underscore parameter _CURSOR_BIND_CAPTURE_INTERVAL to a value lower than 900 seconds (-> the default 15 minutes) as follows:
ALTER SYSTEM SET "_CURSOR_BIND_CAPTURE_INTERVAL"=<seconds>;
转自:http://blog.itpub.net/7728585/viewspace-719037/