辅助表空间

 

 

 


##查看辅助表空间WRH$_ACTIVE_SESSION_HISTORY大小
SELECT owner,
segment_name,
partition_name,
segment_type,
bytes/1024/1024/1024 Size_GB
FROM dba_segments
WHERE segment_name='WRH$_ACTIVE_SESSION_HISTORY';


##清理WRH$_ACTIVE_SESSION_HISTORY
alter session set "_swrf_test_action" = 72;
alter table WRH$_ACTIVE_SESSION_HISTORY truncate partition WRH$_ACTIVE_351045181_0;


##查看awr策略
select * from dba_hist_wr_control;

##查看基线
SELECT dbid, baseline_name, baseline_type, moving_window_size from dba_hist_baseline;

##调整基线天数
exec DBMS_WORKLOAD_REPOSITORY.MODIFY_BASELINE_WINDOW_SIZE(6)

##更改AWR生成策略
exec dbms_workload_repository.modify_snapshot_settings(interval=>60,retention=>1440*6)


##如下程式會從WRH$_ACTIVE_SESSION_HISTORY 表中得到一個最小和最大的snap id
set serveroutput on
declare
CURSOR cur_part IS
SELECT partition_name from dba_tab_partitions
WHERE table_name = 'WRH$_ACTIVE_SESSION_HISTORY';
query1 varchar2(200);
query2 varchar2(200);
TYPE partrec IS RECORD (snapid number, dbid number);
TYPE partlist IS TABLE OF partrec;
Outlist partlist;
begin
dbms_output.put_line('PARTITION NAME SNAP_ID DBID');
dbms_output.put_line('--------------------------- ------- ----------');
for part in cur_part loop
query1 := 'select min(snap_id), dbid from sys.WRH$_ACTIVE_SESSION_HISTORY partition ('||part.partition_name||') group by dbid';
execute immediate query1 bulk collect into OutList;
if OutList.count > 0 then
for i in OutList.first..OutList.last loop
dbms_output.put_line(part.partition_name||' Min '||OutList(i).snapid||' '||OutList(i).dbid);
end loop;
end if;
query2 := 'select max(snap_id), dbid from sys.WRH$_ACTIVE_SESSION_HISTORY partition ('||part.partition_name||') group by dbid';
execute immediate query2 bulk collect into OutList;
if OutList.count > 0 then
for i in OutList.first..OutList.last loop
dbms_output.put_line(part.partition_name||' Max '||OutList(i).snapid||' '||OutList(i).dbid);
dbms_output.put_line('---');
end loop;
end if;
end loop;
end;

 

 

 

关于分区表
--(表及索引多大,多少个分区,在哪一个列建了分区,表及索引的分区的类型是什么,有无子分区)
set linesize 366
col partitioning_type format a10
col subpartitioning_type format a10
col partition_count format 99999
col column_name format a20
col object_type format a10
col blevel format 9
col num_rows format 99999999
col leaf_blocks format 999999
col column_position format 9
col partition_name format a28
col segment_type format a20
col index_name format a28
col table_name format a30
col last_analyzed format date
col status format a8

---01 该表是否是分区表,分区表的分区类型是什么,是否有子分区,分区总数有多少
select partitioning_type,
subpartitioning_type,
partition_count
from dba_part_tables
where table_name ='&1';

--02 该分区表在哪一列上建分区,有无多列联合建分区
select column_name,
object_type,
column_position
from dba_part_key_columns
where name ='&1';



--03 该分区表有多大?
select sum(bytes) / 1024 / 1024
from dba_segments
where segment_name ='&1';

--04 该分区表各分区分别有多大,各个分区名是什么。
select partition_name,
segment_type,
bytes
from dba_segments
where segment_name ='&1';


--05 该分区表的统计信息收集情况
select table_name,
partition_name,
last_analyzed,
partition_position,
num_rows
from dba_tab_statistics t
where table_name ='&1';


--06 查该分区表有无索引,分别什么类型,全局索引是否失效,此外还可看统计信息收集情况。
--(其中status值为N/A 表示分区索引,分区索引是否失效是在dba_ind_partitions中查看)
select table_name,
index_name,
last_analyzed,
blevel,
num_rows,
leaf_blocks,
distinct_keys,
status
from dba_indexes
where table_name ='&1';


--07 该分区表在哪些列上建了索引
select index_name,
column_name,
column_position
from dba_ind_columns
where table_name = '&1';

 

--08 该分区表上的各索引分别有多大。
select segment_name,segment_type,sum(bytes)/1024/1024
from dba_segments
where segment_name in
(select index_name
from dba_indexes
where table_name ='&1')
group by segment_name,segment_type ;

--09 该分区表的索引段的分配情况
select segment_name

猜你喜欢

转载自www.cnblogs.com/bondait/p/9723281.html