Most of cases ORA-10631 found during shrink a table. See below example:
SQL> alter table MM.DAILY_REPORT shrink space;
alter table MM.DAILY_REPORT shrink space
SQL>
ORA-10631: SHRINK clause should not be specified for this object
This error is due to the fact that an object you are trying to shrink has an “function-based” index on it. Objects with function-based indexes cannot be shrunk. To reclaim the space you need to drop and re-create the function-based index after shrinking the object.
Note:
Here is a handy script to locate highly fragmented tables ( top 10):
select *
from (select table_name,
round(((blocks * 8)/1024/1024), 1) "size (GB)",
round((num_rows * avg_row_len / 1024/1024/1024), 1) "actual_data (GB)",
(round(((blocks * 8)/1024/1024), 1) -
round((num_rows * avg_row_len / 1024/1024/1024), 1)) "wasted_space (GB)"
from dba_tables
where (round((blocks * 8), 1) >
round((num_rows * avg_row_len / 1024/1024/1024), 1))
order by 4 desc)
WHERE ROWNUM <= 10;
Before shrink, table row enable must be done.
-- To enable/disable row movement followed by shrink
SQL> alter table owner.table_name enable row movement;
SQL> alter table owner.table_name shrink space;
SQL> alter table owner.table_name disable row movement;
SQL> alter table MM.DAILY_REPORT shrink space;
alter table MM.DAILY_REPORT shrink space
SQL>
ORA-10631: SHRINK clause should not be specified for this object
This error is due to the fact that an object you are trying to shrink has an “function-based” index on it. Objects with function-based indexes cannot be shrunk. To reclaim the space you need to drop and re-create the function-based index after shrinking the object.
Note:
Here is a handy script to locate highly fragmented tables ( top 10):
select *
from (select table_name,
round(((blocks * 8)/1024/1024), 1) "size (GB)",
round((num_rows * avg_row_len / 1024/1024/1024), 1) "actual_data (GB)",
(round(((blocks * 8)/1024/1024), 1) -
round((num_rows * avg_row_len / 1024/1024/1024), 1)) "wasted_space (GB)"
from dba_tables
where (round((blocks * 8), 1) >
round((num_rows * avg_row_len / 1024/1024/1024), 1))
order by 4 desc)
WHERE ROWNUM <= 10;
Before shrink, table row enable must be done.
-- To enable/disable row movement followed by shrink
SQL> alter table owner.table_name enable row movement;
SQL> alter table owner.table_name shrink space;
SQL> alter table owner.table_name disable row movement;
Excellent Blog very imperative good content, this article is useful to beginners and real time
ReplyDeleteemployees.Thank u for sharing...
Oracle ADF Online Training
Oracle DBA Online Training
Oracle APPS Online Training
Since this script relies on the blocks column from dba_tables, you'll need to gather stats again if you want to see the actual space recovered (there's some space that's wasted due to fixed sized columns). You should use "blocks" from dba_segments.
ReplyDelete