Oracle 开发篇+追踪PL/SQL执行情况(层次分析器)

说明:本文为面向PL/SQL开发初学者的指导手册
标签:dbms_hprof、层次分析器、查看执行情况、Tracing PL/SQL Execution
优点:该方法适合分析PL/SQL每个环节的用时详情
易学:文中删去了不需要的多余部分,让初学者一目了然一学就会
温馨提示:如果您发现本文哪里写的有问题或者有更好的写法请留言或私信我进行修改优化


--用途
分析PL/SQL每个环节的用时详情

--授权+准备
grant dba to scott;
create directory d as '/home/oracle/';
grant read,write on directory d to scott;
grant execute on dbms_hprof to scott;

--切换用户
conn scott/tiger

--启动分析(大小写敏感)
--将分析输出到D目录下的指定文件中
exec dbms_hprof.start_profiling('D','s.txt');

--删除存储过程
drop procedure p1;
--创建存储过程
create or replace  procedure  p1
is
begin
  update scott.emp set sal=sal+1;
  commit;
end;
/

--停止分析
exec dbms_hprof.stop_profiling;

--创建analyze表
@?/rdbms/admin/dbmshptab.sql

--转换输出
begin
dbms_output.put_line(dbms_hprof.analyze('D','s.txt'));
end;
/

--查看输出(方法1)(html格式)
[oracle@main ~]$ $ORACLE_HOME/bin/plshprof -output scott_hprof s.txt
PLSHPROF: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
[14 symbols processed]
[Report written to 'scott_hprof.html']

[oracle@main ~]$ ls scott_hprof*
scott_hprof_2c.html  scott_hprof.html     scott_hprof_nsc.html  scott_hprof_tc.html
scott_hprof_2f.html  scott_hprof_md.html  scott_hprof_nsf.html  scott_hprof_td.html
scott_hprof_2n.html  scott_hprof_mf.html  scott_hprof_nsp.html  scott_hprof_tf.html
scott_hprof_fn.html  scott_hprof_ms.html  scott_hprof_pc.html   scott_hprof_ts.html


--查看输出(方法2)(数据库表格式)
select * from scott.dbmshp_runs;
select * from scott.dbmshp_function_info;
select * from scott.dbmshp_parent_child_info;


※ 如果您觉得文章写的还不错, 别忘了在文末给作者点个赞哦 ~

over

猜你喜欢

转载自blog.csdn.net/zzt_2009/article/details/114239877