Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Segment Advisor to analyze the Table that are highly fragmented
1. To reclaim unused space from a table through table shrink command
------------------------------------------------------------------
Step 1= Create a segment advisor for the particular table
variable id number;
begin
declare
name varchar2(100);
descr varchar2(500);
obj_id number;
begin
name:='Manual_Employees';
descr:='Segment Advisor Example';
dbms_advisor.create_task (
advisor_name => 'Segment Advisor',
task_id => :id,
task_name => name,
task_desc => descr);
dbms_advisor.create_object (
task_name => name,
object_type => 'TABLE',
attr1 => 'HR',
attr2 => 'EMPLOYEES',
attr3 => NULL,
attr4 => NULL,
attr5 => NULL,
object_id => obj_id);
dbms_advisor.set_task_parameter(
task_name => name,
parameter => 'recommend_all',
value => 'TRUE');
dbms_advisor.execute_task(name);
end;
end;
/
Once the segment advisor created. It can advice us with the required action to
be taken to reclaim the used storage
select task_name, status from dba_advisor_tasks where owner = 'APPS' and
advisor_name = 'Segment Advisor';
select af.task_name, ao.attr2 segname, ao.attr3 partition, ao.type, af.message
from dba_advisor_findings af, dba_advisor_objects ao
where ao.task_id = af.task_id
and ao.object_id = af.object_id
and ao.owner = 'APPS';