首页 > IT职业 > IT职场 > DBA_HIST_SQLBIND 视图
在调整SQL的步骤中,使用绑定变量是首选。而使用了绑定变量之后,变量传入的不同值会产生不同的执行计划。在以前使用9I的时候,为了模拟得到和生产环境更为接近的数据,执行计划,我有时候不得不尝试传入不同的变量值去测试。而10G的DBA_HIST_SQLBIND在这方面相信会更有帮助
[@more@]先来看看这个视图的详细解释
| Column | Datatype | NULL | Description |
| SNAP_ID | NUMBER | Unique snapshot ID | |
| DBID | NUMBER | Database ID for the snapshot | |
| INSTANCE_NUMBER | NUMBER | Instance number for the snapshot | |
| SQL_ID | VARCHAR2(13) | SQL identifier of the parent cursor in the library cache | |
| NAME | VARCHAR2(30) | Name of the bind variable | |
| POSITION | NUMBER | Position of the bind variable in the SQL statement | |
| DUP_POSITION | NUMBER | If the binding is performed by name and the bind variable is duplicated, then this column gives the position of the primary bind variable. | |
| DATATYPE | NUMBER | Internal identifier for the bind datatype | |
| DATATYPE_STRING | VARCHAR2(15) | Textual representation of the bind datatype | |
| CHARACTER_SID | NUMBER | National character set identifier | |
| PRECISION | NUMBER | Precision (for numeric binds) | |
| SCALE | NUMBER | Scale (for numeric binds) | |
| MAX_LENGTH | NUMBER | Maximum bind length | |
| WAS_CAPTURED | VARCHAR2(3) | Indicates whether the bind value was captured (YES) or not (NO) | |
| LAST_CAPTURED | DATE | 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_STRING | VARCHAR2(4000) | Value of the bind represented as a string | |
| VALUE_ANYDATA | ANYDATA | 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/ ,如需转载,请注明出处,否则将追究法律责任。