Text box

Please note that the problems that i face may not be the same that exist on your environment so please test before applying the same steps i followed to solve the problem .

Thursday 20 October 2011

how to compress all the tables inside a tablespace

1-calculate all the tablespace tables sizes before compression:
select  sum(bytes/1024/1024/1024),segment_name,owner from dba_segments where tablespace_name='TIM_UAT' and segment_type='TABLE' group by segment_name,owner order by 1;
2-generate a script to compress all the tables inside the tablespace given that the table was not compressed before:

 select 'Alter table '||owner||'.'|| table_name||' move compress;' from dba_tables where TABLESPACE_NAME='TIM_EA3' and compression='DISABLED';

3-rebuild all the indexes that was unusable due to the compression:

  select  sum(bytes/1024/1024/1024),segment_name,owner from dba_segments where tablespace_name='TIM_UAT' and segment_type='TABLE' group by segment_name,owner order by 1;

4-calculate the sizes of all the tables inside the tablespace after compression:
select  sum(bytes/1024/1024/1024),segment_name,owner from dba_segments where tablespace_name='TIM_UAT' and segment_type='TABLE' group by segment_name,owner order by 1;

Don't  forget to rebuild all unusable indexes after finishing this process:
select 'Alter index '||owner||'.'||index_name||' rebuild;' from dba_indexes where status='UNUSABLE'

Kindly note that compression is useful when you have alot of redundant data available and will be so beneficial.



No comments:

Post a Comment