oracle dump 转储
生活随笔
收集整理的這篇文章主要介紹了
oracle dump 转储
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、set events命令格式
oracle提供進(jìn)行事件跟蹤及轉(zhuǎn)儲(chǔ)的命令,個(gè)人認(rèn)為在用戶的連接終端(也就是用戶連接到oracle的session)中,執(zhí)行跟蹤事件命令是靈活的、方便的,常用的。使用方法如下:
SQL> alter session set events ‘immediate trace name controlf level 1′;
會(huì)話已更改。
基本命令是“alter session set events ‘…’
引號(hào)中為要指定跟蹤的事件定義,有兩種方法:
1)事件號(hào)方式
一種是在引號(hào)中指定一個(gè)“事件號(hào)(eventnumber)”,指觸發(fā)dump的事件號(hào),事件號(hào)可以是Oracle錯(cuò)誤號(hào)(出現(xiàn)相應(yīng)錯(cuò)誤時(shí)跟蹤指定的事件)或oralce內(nèi)部事件號(hào)(僅當(dāng)同時(shí)使用trace name context 時(shí)),內(nèi)部事件號(hào)在10000到10999之間,不能與immediate關(guān)鍵字同用。
SQL> alter session set events ‘ 10013′;
2)事件名方式
另一種是在引號(hào)中指定“事件名稱(eventname)”,需要加上“trace name”關(guān)鍵字。
SQL> alter session set events ‘trace name controlf ‘;
3)跟蹤級(jí)別
這兩種方式,都需要指定跟蹤事件的級(jí)別,一般為1至10,級(jí)別超高,跟蹤的信息越全。這里有個(gè)解釋:
1 :only the file header
2 :just the file header, the database info record, and checkpoint progress records
3 :all record types, but just the earliest and latest records for circular reuse record types
4 :as above, but includes the 4 most recent records for circular reuse record types
5+ :as above, but the number of circular reuse records included doubles with each level
SQL> alter session set events ‘trace name controlf level 3′;
4)一直跟蹤
在引號(hào)中加入“forever”關(guān)鍵字,放置于后端,且與level關(guān)鍵字之間有一個(gè)逗號(hào)。
SQL> alter session set events ‘trace name controlf forever, level 3′;
5)立即執(zhí)行
在引號(hào)中加入“immediate”關(guān)鍵字,放置于前端。immediate和forever關(guān)鍵字不能同時(shí)使用。
SQL> alter session set events ‘immediate trace name controlf level 3′;
通常這個(gè)例子為常用的使用方法。
2、跟蹤sql的執(zhí)行
通過以下方式可以手動(dòng)的開啟sql的跟蹤
1.select sid,serial#,username,osuser,machine from v$session; //先查詢到session的sid,serial#
2.exec dbms_system.set_sql_trace_in_session(sid,sid_serial#,true); //開始跟蹤
3.exec dbms_system.set_sql_trace_in_session(sid, sid_serial#,false); //停止跟蹤
4.tkprof *.trc *.txt //通過tkprof可以將trc文件轉(zhuǎn)換成易讀的格式(實(shí)際就是一些統(tǒng)計(jì)信息)。
oracle提供進(jìn)行事件跟蹤及轉(zhuǎn)儲(chǔ)的命令,個(gè)人認(rèn)為在用戶的連接終端(也就是用戶連接到oracle的session)中,執(zhí)行跟蹤事件命令是靈活的、方便的,常用的。使用方法如下:
SQL> alter session set events ‘immediate trace name controlf level 1′;
會(huì)話已更改。
基本命令是“alter session set events ‘…’
引號(hào)中為要指定跟蹤的事件定義,有兩種方法:
1)事件號(hào)方式
一種是在引號(hào)中指定一個(gè)“事件號(hào)(eventnumber)”,指觸發(fā)dump的事件號(hào),事件號(hào)可以是Oracle錯(cuò)誤號(hào)(出現(xiàn)相應(yīng)錯(cuò)誤時(shí)跟蹤指定的事件)或oralce內(nèi)部事件號(hào)(僅當(dāng)同時(shí)使用trace name context 時(shí)),內(nèi)部事件號(hào)在10000到10999之間,不能與immediate關(guān)鍵字同用。
SQL> alter session set events ‘ 10013′;
2)事件名方式
另一種是在引號(hào)中指定“事件名稱(eventname)”,需要加上“trace name”關(guān)鍵字。
SQL> alter session set events ‘trace name controlf ‘;
3)跟蹤級(jí)別
這兩種方式,都需要指定跟蹤事件的級(jí)別,一般為1至10,級(jí)別超高,跟蹤的信息越全。這里有個(gè)解釋:
1 :only the file header
2 :just the file header, the database info record, and checkpoint progress records
3 :all record types, but just the earliest and latest records for circular reuse record types
4 :as above, but includes the 4 most recent records for circular reuse record types
5+ :as above, but the number of circular reuse records included doubles with each level
SQL> alter session set events ‘trace name controlf level 3′;
4)一直跟蹤
在引號(hào)中加入“forever”關(guān)鍵字,放置于后端,且與level關(guān)鍵字之間有一個(gè)逗號(hào)。
SQL> alter session set events ‘trace name controlf forever, level 3′;
5)立即執(zhí)行
在引號(hào)中加入“immediate”關(guān)鍵字,放置于前端。immediate和forever關(guān)鍵字不能同時(shí)使用。
SQL> alter session set events ‘immediate trace name controlf level 3′;
通常這個(gè)例子為常用的使用方法。
2、跟蹤sql的執(zhí)行
通過以下方式可以手動(dòng)的開啟sql的跟蹤
1.select sid,serial#,username,osuser,machine from v$session; //先查詢到session的sid,serial#
2.exec dbms_system.set_sql_trace_in_session(sid,sid_serial#,true); //開始跟蹤
3.exec dbms_system.set_sql_trace_in_session(sid, sid_serial#,false); //停止跟蹤
4.tkprof *.trc *.txt //通過tkprof可以將trc文件轉(zhuǎn)換成易讀的格式(實(shí)際就是一些統(tǒng)計(jì)信息)。
總結(jié)
以上是生活随笔為你收集整理的oracle dump 转储的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。