ITPub博客

首页 > IT职业 > IT职场 > DBA_HIST_SQLBIND 视图

DBA_HIST_SQLBIND 视图

原创 IT职场 作者:bulkaunt 时间:2007-05-25 08:59:44 0 删除 编辑

在调整SQL的步骤中,使用绑定变量是首选。而使用了绑定变量之后,变量传入的不同值会产生不同的执行计划。在以前使用9I的时候,为了模拟得到和生产环境更为接近的数据,执行计划,我有时候不得不尝试传入不同的变量值去测试。而10G的DBA_HIST_SQLBIND在这方面相信会更有帮助

[@more@]

先来看看这个视图的详细解释

ColumnDatatypeNULLDescription
SNAP_IDNUMBER Unique snapshot ID
DBIDNUMBER Database ID for the snapshot
INSTANCE_NUMBERNUMBER Instance number for the snapshot
SQL_IDVARCHAR2(13) SQL identifier of the parent cursor in the library cache
NAMEVARCHAR2(30) Name of the bind variable
POSITIONNUMBER Position of the bind variable in the SQL statement
DUP_POSITIONNUMBER If the binding is performed by name and the bind variable is duplicated, then this column gives the position of the primary bind variable.
DATATYPENUMBER Internal identifier for the bind datatype
DATATYPE_STRINGVARCHAR2(15) Textual representation of the bind datatype
CHARACTER_SIDNUMBER National character set identifier
PRECISIONNUMBER Precision (for numeric binds)
SCALENUMBER Scale (for numeric binds)
MAX_LENGTHNUMBER Maximum bind length
WAS_CAPTUREDVARCHAR2(3) Indicates whether the bind value was captured (YES) or not (NO)
LAST_CAPTUREDDATE Date when the bind value was captured. Bind values are captured when SQL statements are executed. To limit the overhead, binds are captured at most every 15 minutes for a given cursor.
VALUE_STRINGVARCHAR2(4000) Value of the bind represented as a string
VALUE_ANYDATAANYDATA Value of the bind represented using the self-descriptive Sys.AnyData datatype. This representation is useful to programmatically decode the value of the bind variable.

例如:

select *from DBA_HIST_SQLBIND where sql_id='gptdqr1wgb1wf' and snap_id=7405;

SNAP_ID DBID INSTANCE_NUMBER SQL_ID NAME POSITION DUP_POSITION DATATYPE DATATYPE_STRING CHARACTER_SID PRECISION SCALE MAX_LENGTH WAS LAST_CAPTURE VALUE_STRING VALUE_ANYDATA()
7405 1955257682 1 gptdqr1wgb1wf :SERVNUMBER 1 1 VARCHAR2(32) 852 32 YES 24-MAY-07 13600290138 ANYDATA()
7405 1955257682 1 gptdqr1wgb1wf :SERVNUMBER 1 1 VARCHAR2(32) 852 32 YES 24-MAY-07 13827680309 ANYDATA()
7405 1955257682 1 gptdqr1wgb1wf :REGION 2 1 VARCHAR2(32) 852 32 YES 24-MAY-07 769 ANYDATA()
7405 1955257682 1 gptdqr1wgb1wf :REGION 2 1 VARCHAR2(32) 852 32 YES 24-MAY-07 662 ANYDATA()
7405 1955257682 1 gptdqr1wgb1wf :SDATE 3 12 DATE 7 YES 24-MAY-07 01/01/07 10:33:09 ANYDATA()
7405 1955257682 1 gptdqr1wgb1wf :SDATE 3 12 DATE 7 YES 24-MAY-07 05/01/07 00:00:00 ANYDATA()
7405 1955257682 1 gptdqr1wgb1wf :EDATE 4 12 DATE 7 YES 24-MAY-07 05/24/07 23:59:59 ANYDATA()
7405 1955257682 1 gptdqr1wgb1wf :EDATE 4 12 DATE 7 YES 24-MAY-07 05/24/07 23:59:59 ANYDATA()
7405 1955257682 1 gptdqr1wgb1wf :ROWNUMBER 5 1 VARCHAR2(32) 852 32 YES 24-MAY-07 5000 ANYDATA()
7405 1955257682 1 gptdqr1wgb1wf :ROWNUMBER 5 1 VARCHAR2(32) 852 32 YES 24-MAY-07 10000 ANYDATA()

格式的不好看,凑合着吧。这里有一个snap_id,不同的ID会捕获到不一样的情况,结合AWR,这对异常或怀疑有异常的SQL分析特别有帮助。

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

上一篇: ORACLE并行
下一篇: expdp进程HANG住了
请登录后发表评论 登录
全部评论

注册时间:2012-09-21

  • 博文量
    15
  • 访问量
    1144758