查看碎片程度高的表SELECT segment_name table_name, COUNT(*) extents FROM dba_segmentsWHERE owner NOT IN (‘SYS’, ‘SYSTEM’)
GROUP BY segment_name
HAVING COUNT(*) = (SELECT MAX(COUNT(*))
FROM dba_segments
GROUP BY segment_name);查找使用CPU多的用户sessionselect a.sid,spid,status,substr(a.program,1,40) prog,a.terminal,osuser,value/60/100 value
from v$session a,v$process b,v$sesstat c
where c.statistic#=12 and c.sid=a.sid and a.paddr=b.addr order by value desc;回滚段的争用情况select name, waits, gets, waits/gets “Ratio”
from v$rollstat a, v$rollname b
where a.usn = b.usn;监控 SGA 中共享缓存区的命中率,应该小于1%select sum(pins) “Total Pins”,
sum(reloads) “Total Reloads”,
sum(reloads) / sum(pins) * 100 libcache,
sum(pinhits – reloads) / sum(pins) “hit radio”,
sum(reloads) / sum(pins) “reload percent”
from v$librarycache;
监控 SGA 中重做日志缓存区的命中率,应该小于1% SELECT name, gets, misses, immediate_gets, immed免费云主机域名iate_misses,
Decode(gets,0,0,misses/gets*100) ratio1,
Decode(immediate_gets+immediate_misses,0,0,
immediate_misses/(immediate_gets+immediate_misses)*100) ratio2
FROM v$latch WHERE name IN (‘redo allocation’, ‘redo copy’);监控log_buffer的使用情况select name,value from v$sysstat where name in (‘redo entries’,’redo buffer allocation retries’)监控SGA中数据库缓冲区的命中率select a.value + b.value “logical_reads”, c.value “phys_reads”,
round(100 * ((a.value+b.value)-c.value) / (a.value+b.value)) “BUFFER HIT RATIO”
from v$sysstat a, v$sysstat b, v$sysstat c
where a.statistic# = 38 and b.statistic# = 39
and c.statistic# = 40;监控表空间的IO比例select df.tablespace_name name,df.file_name “ile”,f.phyrds pyr,
f.phyblkrd pbr,f.phywrts pyw, f.phyblkwrt pbw
from v$filestat f, dba_data_files df
where f.file# = df.file_id
order by df.tablespace_name;监控表空间的使用率SELECT UPPER(F.TABLESPACE_NAME) “表空间名”,
D.TOT_GROOTTE_MB “表空间大小(M)”,
D.TOT_GROOTTE_MB – F.TOTAL_BYTES “已使用空间(M)”,
ROUND((D.TOT_GROOTTE_MB – F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2) “使用比”,
F.TOTAL_BYTES “空闲空间(M)”,
F.MAX_BYTES “最大块(M)”
FROM (SELECT TABLESPACE_NAME,
ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES,
ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES
FROM SYS.DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F,
(SELECT DD.TABLESPACE_NAME,
ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB
FROM SYS.DBA_DATA_FILES DD
GROUP BY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
ORDER BY 4 DESC;监控当前数据库谁在运行什么SQL语句SELECT osuser, username, sql_text
from v$session a, v$sqltext b
where a.sql_address = b.address
order by address, piece;监控等待事件select event,sum(decode(wait_Time,0,0,1)) “rev”,
sum(decode(wait_Time,0,1,0)) “Curr”,count(*) “Tot”
from v$session_Wait
group by event order by 4;监控内存和硬盘的排序比率SELECT name, value
FROM v$sysstat
WHERE name IN (‘sorts (memory)’, ‘sorts (disk)’);监控文件系统的IO比例 select substr(a.file#,1,2) “#”, substr(a.name,1,30) “Name”,
a.status, a.bytes, b.phyrds, b.phywrts
from v$datafile a, v$filestat b
where a.file# = b.file#;在某个用户下找所有的索引select user_indexes.table_name,
user_indexes.index_name,
uniqueness,
column_name
from user_ind_columns, user_indexes
where user_ind_columns.index_name = user_indexes.index_name
and user_ind_columns.table_name = user_indexes.table_name
order by user_indexes.table_type,
user_indexes.table_name,
user_indexes.index_name,
column_position;
假定Oracle数据库发生了以下情形: 1、表空间中,某个表的重要数据被破坏或删除。 2、误用DDL语言更改了表空间中的一个或多个表的结构,因此无法使用闪回来恢复这些表。 3、表被误删,并且已不在回收站中,如使用了带purge选项的删表操作。 那么我们该如何恢…
免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。