关于oracle日常命令

    #以下命令不要改格式,否则很有可能会报错!!!!!!!!

#rman全备查询
set linesize 300                              
col input_size for a12                                                                                                                    
col output_size for a12                                                                                                                   
col input_speed for a12                                                                                                                   
col output_speed for a12                                                                                                                  
col time_taken_display for a12                                                                                                            
col status for a10  
select * from (select session_stamp,start_time,end_time,input_type,status,input_bytes_display input_size,output_bytes_display output_size,
input_bytes_per_sec_display input_speed,output_bytes_per_sec_display output_speed,time_taken_display                        
from v$rman_backup_job_details order by start_time desc) where rownum < 50;


#查询上一次归档信息
select to_char(completion_time,'yyyy-mm-dd') archived_date,thread# instance,count(*) arch_qty,sum(blocks*block_size)/1024/1024 arch_GB
from v$archived_log                                                                                                                  
where archived='YES' and to_char(completion_time,'yyyy-mm-dd')>=to_char(sysdate-1,'yyyy-mm-dd')                                        
group by rollup(to_char(completion_time,'yyyy-mm-dd'),thread#);


#在磁盘上查找最大读写的SQL
SELECT * FROM (SELECT sql_text,disk_reads "total disk",executions "total exec",disk_reads/executions "disk/exec" FRO
M v$sql where executions>0 and is_obsolete='N' and disk_reads !=0 order by 4 desc) where rownum<11;



#数据库cache、buffer命中率(通常应在90%以上,否则需要加大DB_CACHE_SIZE)
select name,physical_reads,db_block_gets,consistent_gets,1-(physical_reads/(db_block_gets+consistent_gets)) "hit rat
io" from v$buffer_pool_statistics where name='DEFAULT';


#检查内存排序性能
select a.name, to_char(value)
from v$statname a, v$sysstat
where a.statistic# = v$sysstat.statistic# and a.name in ('sorts (disk)', 'sorts (memory)', 'sorts (rows)');


#排序命中率
select a.value "Sort(Disk)", b.value "Sort(Memory)",
round(100*(a.value/decode((a.value+b.value), 0,1,(a.value+b.value))),2) "% Ratio (STAY UNDER 5%)"
from v$sysstat a, v$sysstat b
where a.name = 'sorts (disk)' and b.name = 'sorts (memory)';


#数据字典命中率
select round((1-sum(getmisses)/sum(gets))*100,1) "data dictionary hit ratio %"
from v$rowcache;

#共享池大小命中率
select round((sum(gets)-sum(reloads))/sum(gets)*100,1) "libiary cache hit ratio %"
from v$librarycache where namespace
in ('SQL AREA','TABLE/PROCEDURE','BODY','TRIGGER');


#数据缓冲区命中率
select round((1-(phy.value/(cur.value+con.value)))*100,1)||'%' ratio from v$sysstat phy,v$sysstat cur,v$sysstat con where phy.name='physical reads' and cur.name='db block gets' and con.name='consistent gets';


#命中率查询
select round((sum(gets)-sum(reloads))/sum(gets)*100,1) "libiary cache hit ratio %"
from v$librarycache where namespace
in ('SQL AREA','TABLE/PROCEDURE','BODY','TRIGGER');

          欢迎一起探讨开源、技术

猜你喜欢

转载自www.cnblogs.com/smlile-you-me/p/12929283.html
今日推荐