常用指令碼:獲取隱含引數

東北胖子發表於2018-04-16
指令碼涉及:gethidpar.sql 獲取隱含引數
          gettrcname.sql 獲取當前trace檔名稱
          getplan.sql  獲取sql語句的執行計劃,透過v$sql_plan檢視。
gethidpar.sql內容如下:
set linesize 120
col name for a30
col value for a20
col describ for a60
select x.ksppinm name, y.ksppstvl value, x.ksppdesc describ
from sys.x$ksppi x,sys.x$ksppcv y
where x.indx = y.indx
and x.ksppinm like '%&par%'
/
gettrcname.sql 內容如下:
select
a.value || b.symbol || c.instance_name || '_ora_'  || d.spid || '.trc' trace_file_name
from (select value from v$parameter where name = 'user_dump_dest')a,
(select substr(value,-6,1) symbol from v$parameter where name = 'user_dump_dest') b,
(select instance_name from v$instance) c,
(select spid from v$session s,v$process p,v$mystat m where s.paddr = p.addr and s.sid = m.sid and m.statistic#=0) d
/
getplan.sql 內容如下:
set linesize 120
col operation format a55
col cost format 99999
col kbytes format 999999
col object format a25
select hash_value,child_number,
lpad(' ',2*depth) || operation || ' ' || options || decode(id,0,substr(optimizer,1,6) || 'Cost=' || to_char(cost)) operation,
object_name object,
cost,
round(bytes/1024) kbytes
from v$sql_plan
where hash_value in (
    select a.sql_hash_value from v$session a,v$session_wait b
    where a.sid = b.sid and b.event = '&waitevent')
order by hash_value,child_number,id;
 
/
 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/2317695/viewspace-2152964/,如需轉載,請註明出處,否則將追究法律責任。

相關文章