6. 交換分區;
7. 重建相關索引及觸發器(先刪除之再重建).
參考腳本:
select count(*) from t1 where recdate>sysdate-2
create table x2 nologging as select * from t1 where recdate>trunc(sysdate-2)
alter triger trg_t1 disable
delete t1 where recdate>sysdate-2
commit
rename t1 to x1
create table t1 [nologging] partition by range(recdate)
(partition pbefore values less than (trunc(sysdate-2)),
partition pmax values less than (maxvalue))
as select * from x1 where 1=2
alter table t1 exchange partition pbefore with table x1
alter table t1 exchange partition pmax with table x2
drop table x2
[重建觸發器]
drop table x1
1.1.4 參考材料:
如果表中預期的數據量較大,通常都需要考慮使用分區表,確定使用分區表后,還要確定什么類型的分區(range partition、hash partition、list partition等)、分區區間大小等。分區的創建最好與程序有某種默契,偶曾經創建分區表,按自然月份定義分區的,但程序卻在查詢時默認的開始時間與結束時間是:當前日期-30至當前日期,比如當天是9.18號,那查詢條件被產生為8.18-9.18,結果分區后并不沒有大幅提高性能,后來對程序的查詢日期做了調整,按自然月查詢,系統的負載小了很多。
文章來源于領測軟件測試網 http://www.kjueaiud.com/