Thứ Ba, 1 tháng 12, 2020

Quản lý Index Partition trong Oracle Database

--1.CHECK
select a.* from DBA_PART_INDEXES a, DBA_TAB_PARTITIONS b where a.owner=B.TABLE_OWNER and a.table_name=B.TABLE_NAME and a.owner not like 'SYS%' and b.partition_name like '%20131231';

-- Script rebuild index partititon unusable
select 'alter index ' || index_owner || '.' || index_name || ' rebuild partition ' || partition_name || ' tablespace INDX nologging parallel 8 online;' from dba_ind_partitions where status='UNUSABLE';


-- Script rebuild các partition index 
--+ Bước 1: Rebuild
select 'alter index ' || index_owner || '.' || index_name || ' rebuild partition ' || partition_name || ' tablespace INDX' ||substr(partition_name,5,4)||' nologging parallel 8 online;' from dba_ind_partitions where 
index_owner='APP_OWNER'
and index_name in (
'index_name_1',
'index_name_2'
)
order by partition_name desc
;
--+ Bước 2: Nologging noparallel
alter index app_owner.index_name_1 noparallel nologging;
alter index app_owner.index_name_2 noparallel nologging;


--2. CREATE
CREATE INDEX user1.IDX_SUB_ID ON  user1.table1
(SUB_ID)
 NO LOGGING 
LOCAL PARALLEL 4 ONLINE;

Alter index user1.IDX_SUB_ID noparallel;

--3. ADD PARTITON
 --Khi thêm partition cho bảng thì index trong bảng đó sẽ tự động có partition, nhưng cần rebuild lại index

-- .REBUILD partition ---
ALTER INDEX idx_sales REBUILD PARTITION DATA20140401 TABLESPACE INDX2014;
-- chuyen sang tablspace khac đồng thời rebuild

alter index ITEM_IDX rebuild partition TEST_Q1_JAN tablespace PART1 online parallel 10 nologging; 

-- Rebuild lại partition DATA201107 của index
alter index user1.WS_LOG_I1 rebuild partition  DATA201107  online   parallel 64 nologging;

select 'alter index ' || owner ||'.' || segment_name ||' rebuild partition ' || partition_name || ' tablespace INDX' || substr(partition_name,5,4) || ' nologging parallel 4 online;'
from dba_segments where segment_type like 'INDEX%' and owner='user1' and segment_name not like '%$%' and(tablespace_name like 'DATA2007%' or tablespace_name like 'DATA2008')
order by owner, segment_name, partition_name;


   
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH: 📧 Mail: binhoracle@gmail.com ☎️ Mobile: 0902912888 ⚡️ Skype: tranbinh48ca 👨 Facebook: https://www.facebook.com/BinhOracleMaster 👨 Inbox Messenger: https://m.me/101036604657441 (profile) 👨 Fanpage: https://www.facebook.com/tranvanbinh.vn 👨 Inbox Fanpage: https://m.me/tranvanbinh.vn 👨👩 Group FB: https://www.facebook.com/groups/OracleDBAVietNam 👨 Website: http://www.tranvanbinh.vn 👨 Blogger: https://tranvanbinhmaster.blogspot.com 🎬 Youtube: http://bit.ly/ytb_binhoraclemaster 👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi 👨 Linkin: https://www.linkedin.com/in/binhoracle 👨 Twitter: https://twitter.com/binhoracle 👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội #OracleTutorial #OracleDBA #OracleDatabaseAdministration #học oracle database #oca #ocp #oce #ocm

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master