Oracle 10046事件跟踪绑定变量具体值


10046跟踪绑定变量具体值

1.建立测试表
SQL>  create table t (x varchar2(12));

Table created.

SQL> desc t
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 X                                                  VARCHAR2(12)

2.使用绑定变量插入数据
SQL> declare
  2    v_bindvalue char(8) := 'hfmgdcng' ;
  3  begin
  4    insert into t values (v_bindvalue);
  5  end;
  6  /

PL/SQL procedure successfully completed.

SQL>
SQL> select * from t;

X
------------
hfmgdcng

3.10046时间跟踪设置
alter session set events '10046 trace name context forever, level 4';

SQL> alter session set events '10046 trace name context forever, level 4';

Session altered.


4.继续使用绑定变量插入数据

SQL> declare
  2    v_bindvalue char(12) := 'hfmgdcng' ;
  3  begin
  4    insert into t values (v_bindvalue);
  5  end;
  6  /

PL/SQL procedure successfully completed.

SQL> select * from t;

X
------------
hfmgdcng
hfmgdcng

5.查看相关的trace文件

[root@oradb udump]# more orcl_ora_3324.trc
/oracle/admin/orcl/udump/orcl_ora_3324.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
ORACLE_HOME = /oracle/product/10.2
System name:    Linux
Node name:      oradb
Release:        2.6.18-308.el5
Version:        #1 SMP Tue Feb 21 20:05:41 EST 2012
Machine:        i686
Instance name: orcl
Redo thread mounted by this instance: 1
Oracle process number: 15
Unix process pid: 3324, image: oracle@oradb (TNS V1-V3)

*** 2013-08-20 17:45:46.932
*** ACTION NAME:() 2013-08-20 17:45:46.932
*** MODULE NAME:(SQL*Plus) 2013-08-20 17:45:46.932
*** SERVICE NAME:(SYS$USERS) 2013-08-20 17:45:46.932
*** SESSION ID:(159.5) 2013-08-20 17:45:46.932
=====================
PARSING IN CURSOR #2 len=68 dep=0 uid=56 oct=42 lid=56 tim=1344718698176309 hv=1896049376 ad='2995d71c'
alter session set events '10046 trace name context forever, level 4'
END OF STMT
EXEC #2:c=0,e=2,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=1344718698176307
=====================
PARSING IN CURSOR #8 len=95 dep=0 uid=56 oct=47 lid=56 tim=1344718702594931 hv=3237834723 ad='2995ddd8'
declare
  v_bindvalue char(12) := 'hfmgdcng' ;
begin
  insert into t values (v_bindvalue);
end;
END OF STMT
PARSE #8:c=0,e=124,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=1344718702594919
BINDS #8:
=====================
PARSING IN CURSOR #1 len=27 dep=1 uid=56 oct=2 lid=56 tim=1344718702595808 hv=3116513188 ad='2995dadc'
INSERT INTO T VALUES (:B1 )
END OF STMT
PARSE #1:c=1000,e=791,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=1,tim=1344718702595798
BINDS #1:
kkscoacd
 Bind#0
  oacdty=96 mxl=32(12) mxlc=00 mal=00 scl=00 pre=00
  oacflg=13 fl2=206001 frm=01 csi=852 siz=32 off=0
  kxsbbbfp=b7f64730  bln=32  avl=12  flg=09
  value="hfmgdcng    "
EXEC #1:c=1000,e=670,p=0,cr=1,cu=3,mis=1,r=1,dep=1,og=1,tim=1344718702596881
EXEC #8:c=2000,e=2005,p=0,cr=1,cu=3,mis=0,r=1,dep=0,og=1,tim=1344718702596968

4.分析其中的文件

 Bind#0
  oacdty=96 mxl=32(12) mxlc=00 mal=00 scl=00 pre=00
  oacflg=13 fl2=206001 frm=01 csi=852 siz=32 off=0
  kxsbbbfp=b7f64730  bln=32  avl=12  flg=09
  value="hfmgdcng    "
EXEC #1:c=1000,e=670,p=0,cr=1,cu=3,mis=1,r=1,dep=1,og=1,tim=1344718702596881
EXEC #8:c=2000,e=2005,p=0,cr=1,cu=3,mis=0,r=1,dep=0,og=1,tim=1344718702596968

可以看到 value="hfmgdcng    "  长度为12

继续往后
SQL> variable x char(5)
SQL> exec :x := 'hfmgd';

PL/SQL procedure successfully completed.

SQL> alter session set events '10046 trace name context forever, level 4';

Session altered.

SQL> select * from t where x=:x;

X
------------
hfmgd

variable x char(5)
exec :x := 'hfmgd';
alter session set sql_trace = true
select * from t where x=:x
alter session set sql_trace = flase

PARSE #3:c=1000,e=308,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=1,tim=1344719449388107
BINDS #3:
kkscoacd
 Bind#0
  oacdty=96 mxl=32(05) mxlc=00 mal=00 scl=00 pre=00
  oacflg=10 fl2=0001 frm=01 csi=852 siz=32 off=0
  kxsbbbfp=b7efd780  bln=32  avl=05  flg=05
  value="hfmgd"
EXEC #3:c=1000,e=810,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=1,tim=1344719449389582
FETCH #3:c=1999,e=1478,p=5,cr=7,cu=0,mis=0,r=1,dep=1,og=1,tim=1344719449391060
STAT #3 id=1 cnt=1 pid=0 pos=1 obj=0 op='SORT AGGREGATE (cr=7 pr=5 pw=0 time=1469 us)'
STAT #3 id=2 cnt=3 pid=1 pos=1 obj=51576 op='TABLE ACCESS FULL T (cr=7 pr=5 pw=0 time=1440 us)'
BINDS #2:
kkscoacd
 Bind#0
  oacdty=96 mxl=32(10) mxlc=00 mal=00 scl=00 pre=00
  oacflg=03 fl2=1000000 frm=01 csi=852 siz=32 off=0
  kxsbbbfp=b7ee28d8  bln=32  avl=05  flg=05
  value="hfmgd"
EXEC #2:c=6999,e=6419,p=6,cr=10,cu=0,mis=0,r=0,dep=0,og=1,tim=1344719449391778
FETCH #2:c=0,e=55,p=0,cr=3,cu=0,mis=0,r=1,dep=0,og=1,tim=1344719449392148
FETCH #2:c=0,e=43,p=0,cr=4,cu=0,mis=0,r=0,dep=0,og=1,tim=1344719449393130
STAT #2 id=1 cnt=1 pid=0 pos=1 obj=51576 op='TABLE ACCESS FULL T (cr=7 pr=0 pw=0 time=46 us)'

你可能感兴趣的:(oracle,绑定变量,10046)