Oracle DBA 管理脚本

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Oracle DBA 管理脚本

海量数据库资料下载

/forum-160286-1.html

Oracle DBA 管理脚本

--监控索引是否使用

alter index &index_name monitoring usage;

alter index &index_name nomonitoring usage;

select * from v$object_usage where index_name = &index_name;

--求数据文件的I/O分布

select ,phyrds,phywrts,phyblkrd,phyblkwrt,singleblkrds,readtim,writetim

from v$filestat fs,v$dbfile df

where fs.file#=df.file# order by ;

--求某个隐藏参数的值

col ksppinm format a54

col ksppstvl format a54

select ksppinm, ksppstvl

from x$ksppi pi, x$ksppcv cv

where cv.indx=pi.indx and pi.ksppinm like '\_%' escape '\' and pi.ksppinm like '%meer%';

--求系统中较大的latch

select name,sum(gets),sum(misses),sum(sleeps),sum(wait_time)

from v$latch_children

group by name having sum(gets) > 50 order by 2;

--求归档日志的切换频率(生产系统可能时间会很长)

select start_recid,start_time,end_recid,end_time,minutes from (select test.*, rownum as rn

from (select b.recid start_recid,to_char(b.first_time,'yyyy-mm-dd hh24:mi:ss') start_time,

a.recid end_recid,to_char(a.first_time,'yyyy-mm-dd hh24:mi:ss')

end_time,round(((a.first_time-b.first_time)*24)*60,2) minutes

from v$log_history a,v$log_history b where a.recid=b.recid+1 and b.first_time > sysdate - 1

order by a.first_time desc) test) y where y.rn < 30

--求回滚段正在处理的事务

select ,b.xacts,c.sid,c.serial#,d.sql_text

from v$rollname a,v$rollstat b,v$session c,v$sqltext d,v$transaction e

where n=n and n=e.xidusn and c.taddr=e.addr

and c.sql_address=d.address and c.sql_hashvalue=d.hash_value order by

,c.sid,d.piece;

--求出无效的对象

select 'alter procedure '||object_name||' compile;'

from dba_objects

where status='INVALID' and wner='&' and object_type in ('PACKAGE','PACKAGE BODY');

/

select owner,object_name,object_type,status from dba_objects where

status='INVALID';

--求process/session的状态

select p.pid,p.spid,s.program,s.sid,s.serial#

from v$process p,v$session s where s.paddr=p.addr;

--求当前session的状态

select ,ms.value

from v$mystat ms,v$statname sn

where ms.statistic#=sn.statistic# and ms.value > 0;

--求表的索引信息

select ui.table_name,ui.index_name

from user_indexes ui,user_ind_columns uic

where ui.table_name=uic.table_name and ui.index_name=uic.index_name

and ui.table_name like '&table_name%' and uic.column_name='&column_name';

--显示表的外键信息

col search_condition format a54

select table_name,constraint_name

from user_constraints

where constraint_type ='R' and constraint_name in (select constraint_name from user_cons_columns where column_name='&1');

select rpad(child.table_name,25,' ') child_tablename,

rpad(cp.column_name,17,' ') referring_column,rpad(parent.table_name,25,' ') parent_tablename,

相关文档
最新文档