查询v$sql_bind_capture,如果查不到,再去查dba_hist_sqlstat或dba_hist_sqlbind中查询
v$sql_bind_capture 只能查where之后跟的绑定变量值。
dba_hist这种default 是15分钟收集一次。短时间内可能拿不到值。
create table t (n number(10),v varchar2(3000));
declare
n number(10);
v varchar2(32767);
begin
n :=5;
v :='xxxxx';
execute immediate 'insert into t values(:n,:v)' using n,v;
commit;
end;
/
declare
n number(10);
v varchar2(32767);
begin
n :=5;
v :='xxxxx';
execute immediate 'insert into t select * from t where n =:n and v = :v' using n,v;
commit;
end;
/
select sql_text,sql_id,version_count,executions from v$sqlarea where sql_text like 'insert into t%';
select sql_id ,name ,position,datatype_string,last_captured,value_string from v$sql_bind_capture where sql_id='21mycdpm39kzv';
select sql_id ,name ,position,datatype_string,last_captured,value_string from v$sql_bind_capture where sql_id='6xjjj5u2z3m8p';
select snap_id,dbms_sqltune.extract_bind(bind_data,1).value_string bind1,dbms_sqltune.extract_bind(bind_data,2).value_string bind2 from dba_hist_sqlstat where sql_id ='21mycdpm39kzv' order by snap_id;
_cursor_bind_capture_interval
最后
以上就是无聊手链最近收集整理的关于《基于ORACLE的SQL优化读书》笔记 得到绑定变量值的全部内容,更多相关《基于ORACLE的SQL优化读书》笔记内容请搜索靠谱客的其他文章。
发表评论 取消回复