zoukankan      html  css  js  c++  java
  • 获取oracle sql语句中绑定变量值的方法

    在诊断 sql的性能问题时,我们有时候须要获取其绑定变量的实际值,然后将此实际值带入到sql语句其中,用原来的sql构成select语句(带where条件),实际的运行一下,看一下选择性怎样。

    本文就是说获取其绑定变量值的方法。本文的编写得到枯荣长老的帮助,在此表示感谢。

    本文适用于与oracle 10G或者更高版本号的db。

    alter session set nls_date_format = 'yyyy-mm-dd,hh24:mi:ss';
    set linesize 400
    col sql_Id format a20
    col name format a20
    col datatype_string format a14
    col value_string format a20
     
    --这个sql从内存中读取绑定变量值信息,若是不在内存中,则使用下一个sql
    select sql_id,name, datatype_string, last_captured,value_string from v$sql_bind_capture where sql_id='dxfcacn4t4ppw' order by LAST_CAPTURED,POSITION;
     
    --这个sql从awr中读取绑定变量值信息
    select instance_number,  sql_id,name, datatype_string, last_captured,value_string from dba_hist_sqlbind where sql_id='fahv8x6ngrb50'order by LAST_CAPTURED,POSITION;

  • 相关阅读:
    poj_2352树状数组
    poj_2187凸包,暴力解法
    zoj_3735,dp,长沙站j题
    hdu_1698线段树成段更新
    poj_2828线段树,逆序插入
    poj_3371
    poj_3071概率dp
    hdu_2191多重背包
    poj_1185状压dp
    css-margin
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/4082287.html
Copyright © 2011-2022 走看看