create
or replace procedure P_move_FX_RATE
as
cursor cur is select INDEX_NAME from user_indexes where TABLE_NAME='FX_RATE';
v_index varchar(100);
begin
execute immediate 'alter table SCOTT.FX_RATE enable row movement';
execute immediate 'alter table SCOTT.FX_RATE move';
open cur;
loop
fetch cur into v_index;
exit when cur%notfound;
execute immediate 'alter index SCOTT.'||v_index||' rebuild online';
end loop;
close cur;
execute immediate 'alter table SCOTT.FX_RATE disable row movement';
dbms_stats.gather_table_stats('TPSHKPA1','FX_RATE',method_opt=>'FOR
ALL COLUMNS SIZE AUTO',degree=>4,cascade=>TRUE);
end
P_move_FX_RATE;
/
check
and capture snapshot of the table and index size before and after
shrink :
select
bytes/1024/1024 MB from user_segments where segment_name='FX_RATE';
select INDEX_NAME,INDEX_TYPE,TABLE_OWNER,TABLE_NAME,STATUS from user_indexes
where TABLE_NAME='FX_RATE';
select
bytes/1024/1024 MB from user_segments where segment_name in
('PK_FX_RATE','IDX_FX_RATE_1','IDX_FX_RATE_2','IDX_FX_RATE_101');
There
may be other indexes in different env. Please replace the index name in above
sql.
Manually
shrink FX rate table
begin
P_move_FX_RATE;
end;
setup
schedule job run purge everyday 2:00am HKT. ( Login as SCOTT )
Please
check parameter job_queue_processes (login as sysdba) , it should not be 0. If
it's 0, the job will not run, then alter system set job_queue_processes=20;
Login as SCOTT (Weekly once on Sunday)
declare
my_job number;
begin
dbms_job.submit(
job => my_job,
what =>'P_move_FX_RATE;',
next_date => sysdate,
interval =>'trunc(next_day(sysdate,''SUNDAY''))+19/24'
);
commit;
end;
/
After
the jobs created, please capture snapshot of below sql to check :
select
job,schema_user,LAST_DATE,NEXT_DATE,interval,what from user_jobs;
No comments:
Post a Comment
Thank for showing interest in giving comments/feedback/suggestions
Note: Only a member of this blog may post a comment.