SYSAUX表空间清除AWR快照

查看表空间信息

select * from (
Select a.tablespace_name,
to_char(a.bytes/1024/1024,'999,999.999') total_bytes,
to_char(b.bytes/1024/1024,'999,999.999') free_bytes,
to_char(a.bytes/1024/1024 - b.bytes/1024/1024,'999,999.999') use_bytes,
to_char((1 - b.bytes/a.bytes)*100,'99.99') || '%' use
from (select tablespace_name,
sum(bytes) bytes
from dba_data_files
group by tablespace_name) a,
(select tablespace_name,
sum(bytes) bytes
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
union all
select c.tablespace_name,
to_char(c.bytes/1024/1024,'999,999.999') total_bytes,
to_char( (c.bytes-d.bytes_used)/1024/1024,'999,999.999') free_bytes,
to_char(d.bytes_used/1024/1024,'999,999.999') use_bytes,
to_char(d.bytes_used*100/c.bytes,'99.99') || '%' use
from
(select tablespace_name,sum(bytes) bytes
from dba_temp_files group by tablespace_name) c,
(select tablespace_name,sum(bytes_cached) bytes_used
from v$temp_extent_pool group by tablespace_name) d
where c.tablespace_name = d.tablespace_name
);

查看SYSAUX信息

set linesize 120
set pagesize 100
 
COLUMN "Item" FORMAT A25
COLUMN "Space Used (GB)" FORMAT 999.99
COLUMN "Schema" FORMAT A25
COLUMN "Move Procedure" FORMAT A40
 
SELECT  occupant_name "Item",
    space_usage_kbytes/1048576 "Space Used (GB)",
    schema_name "Schema",
    move_procedure "Move Procedure"
FROM v$sysaux_occupants
ORDER BY 1
/

修改统计信息,默认保留31天,修改为15天,过期的统计信息会自动被删除

#查询统计信息保留时间
select dbms_stats.get_stats_history_retention from dual;
#修改保留时间为15天
exec dbms_stats.alter_stats_history_retention(15);

修改AWR保留时间为7天(7*24*60),每小时搜集一次

begin
     dbms_workload_repository.modify_snapshot_settings(
     interval => 60,
     retention => 10080,--分钟
     topnsql => 100
     );
end;

这里 691200(8*24*60*60),604800(7*24*60*60)都是以秒为单位的。发现执行报错,因为当前系统移动窗口大于现在所设的时间窗口。

查看系统的当前的MOVING_WINDOW_SIZE

select dbid,baseline_name,baseline_type,moving_window_size from dba_hist_baseline;

配置窗口为7

exec dbms_workload_repository.modify_baseline_window_size(7);

再次执行AWR快照保存时间的SQL

删除AWR快照

#查看AWR快照id
select min(snap_id),max(snap_id) from dba_hist_snapshot;
#删除快照最早24小时的快照
exec dbms_workload_repository.drop_snapshot_range(low_snap_id =>4330,high_snap_id => 4330+24);

猜你喜欢

转载自blog.csdn.net/sandy9919/article/details/81665820