1,自SESSION内TRACE取得方法。
Sql代码
//取得开始
ALTER SESSION SET TIMED_STATISTICS = TRUE;
ALTER SESSION SET SQL_TRACE = TRUE;
//SQL执行
..............................
..............................
//取得终了
ALTER SESSION SET TIMED_STATISTICS = FALSE;
ALTER SESSION SET SQL_TRACE = FALSE;
//取得结果
D:Oracleproduct10.2.0adminorcludumporcl_ora_360.trc
TKPROF orcl_ora_360.trc report.txt
2,指定用户的指定SESSION的TRACE取得方法。
Sql代码
//找出要检测的SID和SERIAL
SELECT SID, STATUS,
SUBSTR(USERNAME, 1, 8) USERNAME,
SUBSTR(SCHEMANAME, 1, 8) SCHEMANAME,
SUBSTR(OSUSER, 1, 16) OSUSER,
SUBSTR(MACHINE, 1, 16) MACHINE,
SUBSTR(PROGRAM, 1, 16) PROGRAM,
SERIAL#
FROM V$SESSION
WHERE USERNAME IS NOT NULL
ORDER BY SID;
//取得开始
EXEC DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION(157, 262, TRUE);
//SQL执行
....................................
....................................
//取得结束
EXEC DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION(157, 262, FALSE);