[20121101]tkprof抽取sql語句.txt
[20121101]tkprof抽取sql語句.txt
有時候跟蹤分析sql語句,並不是要看裡面的遞迴的執行,或者效能問題.而是要收集跟蹤命令的執行序列.
檢視tkprof的幫助:
Usage: tkprof tracefile outputfile [explain= ] [table= ]
[print= ] [insert= ] [sys= ] [sort= ]
table=schema.tablename Use 'schema.tablename' with 'explain=' option.
explain=user/password Connect to ORACLE and issue EXPLAIN PLAN.
print=integer List only the first 'integer' SQL statements.
aggregate=yes|no
insert=filename List SQL statements and data inside INSERT statements.
sys=no TKPROF does not list SQL statements run as user SYS.
record=filename Record non-recursive statements found in the trace file.
...
有一個引數record=filename,可以記錄跟蹤整個sql語句序列,自己做一個簡單測試看看:
alter session set events '10046 trace name context forever, level 12';
show parameter cursor;
drop table t purge ;
create table t (a number);
insert into t values(1);
commit ;
insert into t values(2);
rollback;
variable va number;
exec :va := 1
select * from t where a=:va;
desc t
alter session set events '10046 trace name context off';
確定跟蹤檔案:
$ tkprof /u01/app/oracle11g/diag/rdbms/test/test/trace/test_ora_30100.trc record=aaa.sql
SELECT NAME NAME_COL_PLUS_SHOW_PARAM,DECODE(TYPE,1,'boolean',2,'string',3,'integer',4,'file',5,'number', 6,'big integer', 'unknown') TYPE,DISPLAY_VALUE VALUE_COL_PLUS_SHOW_PARAM FROM V$PARAMETER WHERE UPPER(NAME) LIKE UPPER(:NMBIND_SHOW_OBJ) ORDER BY NAME_COL_PLUS_SHOW_PARAM,ROWNUM ;
drop table t purge ;
create table t (a number) ;
insert into t values(1) ;
commit ;
insert into t values(2) ;
rollback ;
BEGIN :va := 1; END;
/
select * from t where a=:va ;
alter session set events '10046 trace name context off' ;
--除desc t外,其他都記錄下來.
--show parameter cursor;變成了
SELECT NAME NAME_COL_PLUS_SHOW_PARAM, DECODE(TYPE, 1,'boolean', 2,'string', 3,'integer', 4,'file', 5,'number', 6,'big integer', 'unknown') TYPE, DISPLAY_VALUE
VALUE_COL_PLUS_SHOW_PARAM
FROM V$PARAMETER
WHERE UPPER(NAME) LIKE UPPER(:NMBIND_SHOW_OBJ)
ORDER BY NAME_COL_PLUS_SHOW_PARAM, ROWNUM ;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-748041/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20160704]從跟蹤檔案抽取sql語句.txtSQL
- 使用SQL TRACE和TKPROF觀察SQL語句執行結果SQL
- [20150705]從AWR抽取有問題的sql語句.txtSQL
- [20131031]從跟蹤檔案中抽取sql語句.txtSQL
- 透過java程式抽取日誌中的sql語句JavaSQL
- 通過java程式抽取日誌中的sql語句JavaSQL
- [20150403]修正sql語句.txtSQL
- [20170103]sql語句過載.txtSQL
- SQL語句SQL
- Java中如何解析SQL語句、格式化SQL語句、生成SQL語句?JavaSQL
- [20170703]SQL語句分析執行過程.txtSQL
- [20131204]sql語句優化.txtSQL優化
- [20151221]sql語句優化.txtSQL優化
- [20141013]奇怪的sql語句.txtSQL
- [20150527]跟蹤單個sql語句.txtSQL
- [20240320]空格與sqlpus的sql語句.txtSQL
- [20240607]PL/SQL中sql語句的註解.txtSQL
- sql語句大全SQL
- 共享SQL語句SQL
- SQL語句整理SQL
- SQL基本語句SQL
- 精妙Sql語句SQL
- SQL語句集合SQL
- oracle sql語句OracleSQL
- sql語句 求救!SQL
- SQL精妙語句SQL
- SQL語句收集SQL
- 常用SQL語句SQL
- sql常用語句SQL
- [20201210]sql語句優化.txtSQL優化
- 【SQL】10 SQL UPDATE 語句SQL
- 【SQL】11 SQL DELETE 語句SQLdelete
- [20150724]無法通過sql_id找到sql語句.txtSQL
- [20220117]超長sql語句.txtSQL
- [20201105]再分析sql語句.txtSQL
- [20220329]是否開發寫錯sql語句.txtSQL
- [20220331]如何調整sql語句.txtSQL
- [20160407]sql語句父子游標的堆轉儲.txtSQL