实际工作中,经常需要跑一些SQL脚本,并且需要跟踪该脚本的日志,此处总结了一下如何更改该脚本让其自动写日志:
/**********************************************************/
/**Add this at the head of the script to trace the script**/
spool D:\dba\MF_bcc_purge\bcc_purge.log
alter session set sql_trace=true;
SELECT 'TKPROF ' ||tracefile||' '||tracefile||'.out' as TRACEFILE FROM v$process WHERE addr IN (SELECT paddr FROM v$session WHERE sid IN (SELECT sid FROM v$mystat WHERE ROWNUM = 1));
set timing on
set echo on
/**********************************************************/
--here is the concept of the script.
/**********************************************************/
set echo off
/**Add this at the end of the script to trace the script**/
alter session set sql_trace=false;
spool off
/**********************************************************/
本文介绍了一种在运行SQL脚本时自动记录日志的方法,包括开启SQL追踪、设置定时及回显等功能,便于后续追踪及调试。
207

被折叠的 条评论
为什么被折叠?



