ITPub博客

首页 > 数据库 > SQL Server > 完善查询绑column valuewwwtl503com_153316O3951string format a定变量脚本bind_cap

完善查询绑column valuewwwtl503com_153316O3951string format a定变量脚本bind_cap

原创 SQL Server 作者:wwwljxbscom 时间:2021-01-13 16:15:50 0 删除 编辑

--//今天查询一个语句绑定变量值,发现值查询结果有点大,有时候并不需要查看全部.
--//修改如下:

$ cat bind_cap.sql
set verify off
column value_string format a50
column datatype_string format a15
break on sql_id on child_number  skip 1
select  replace(sql_fulltext,chr(13),'') c200 from v$sql where sql_id='&1' and rownum<=1;

SELECT sql_id,
       child_number,
       was_captured,
       name,
       position,
       max_length,
       last_captured,
       datatype_string,
       DECODE (
          datatype_string,
          'DATE', TO_CHAR (TO_DATE (value_string, 'mm/dd/yy hh24:mi:ss'),
                           'yyyy/mm/dd hh24:mi:ss'),
          value_string)
          value_string,
          decode(datatype_string,'TIMESTAMP',ANYDATA.accesstimestamp (value_anydata)) c30
  FROM v$sql_bind_capture
 WHERE sql_id = '&1' and was_captured='YES' and  DUP_POSITION is null and lower(name) like lower('%'||nvl('&&2',name)||'%')
 order by child_number,was_captured,position;
clear break

$ cat bind_cap_awr.sql
set verify off
prompt
prompt @bind_cap_awr sql_id [column]
prompt
column value_string format a50
column datatype_string format a15
break on snap_id on sql_id on was_captured on last_captured skip 1

select  replace(sql_fulltext,chr(13),'') c200 from v$sql where sql_id='&1' and rownum<=1;
--select  replace(sql_text,chr(13),'') c200 from DBA_HIST_SQLTEXT where sql_id='&1' and rownum<=1;

SELECT snap_id,
INSTANCE_NUMBER,
         sql_id,
         was_captured,
         last_captured,
         name,
         position,
         max_length,
         datatype_string,
         DECODE (
            datatype_string,
            'DATE', TO_CHAR (TO_DATE (value_string, 'mm/dd/yy hh24:mi:ss'),
                             'yyyy/mm/dd hh24:mi:ss'),
            value_string)
            value_string,
            decode(datatype_string,'TIMESTAMP',ANYDATA.accesstimestamp (value_anydata)) c30
    FROM DBA_HIST_SQLBIND
   WHERE sql_id = '&1' AND was_captured = 'YES' and  dup_position is null and lower(name) like lower('%'||nvl('&&2',name)||'%')
ORDER BY snap_id ,last_captured, was_captured, position;
clear break

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/69993067/viewspace-2749746/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2021-01-12

  • 博文量
    13
  • 访问量
    5335