1. 程式人生 > 資料庫 >轉 OracLe 資料清理

轉 OracLe 資料清理

sq1:
檢查是否是 分割槽表
select table_owner,table_name,partition_name from dba_tab_partitions where table_owner='OSTA';


sql2:
核對分割槽:
select table_name,t.partition_name,SUBPARTITION_COUNT,T.blocks*8192/1024/1024/1024 size_gb from dba_tab_partitions t
where t.table_name in(
'_END')
order by 1;

核對分割槽數量
select table_name,count(*) from dba_tab_partitions t

where t.table_name in (
'HIST',
'group by table_name
order by 2;


3.核對索引型別:
##判斷索引是否失效
select owner,table_name,index_name,i.index_type,i.partitioned,i.uniqueness,status from dba_indexes i where i.status='UNUSABLE';

##判斷分割槽索引是否 local 還是 gloable,有值返回就是local, 沒有值返回就是gloable
select locality,ALIGNMENT,index_name,table_name from dba_part_indexes i where i.table_name in

(
'E00');


##判斷分表上所有的索引
select owner,table_name,index_name,i.index_type,i.partitioned,i.uniqueness,status from dba_indexes i
where i.table_name in
(
'E002_R')

 


#####建議修改索引型別為

舉例如下,可以考慮建立成local 型別的分割槽索引,而不是預設全域性索引。
CREATE INDEX local_one ON employees (employee_id) LOCAL;