0% found this document useful (0 votes)
36 views

Segment Advisor

The document creates a segment advisor task called "SEGMENT_ADVISOR" to analyze the "DBO.UPT" table. It executes the task and views the findings, then alters the table to enable row movement and shrink the space. It also describes how to shrink a table that has a functional based index by dropping and recreating the index.

Uploaded by

mehul dholakiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Segment Advisor

The document creates a segment advisor task called "SEGMENT_ADVISOR" to analyze the "DBO.UPT" table. It executes the task and views the findings, then alters the table to enable row movement and shrink the space. It also describes how to shrink a table that has a functional based index by dropping and recreating the index.

Uploaded by

mehul dholakiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

variable id number;

declare v_name varchar2(100);


v_descr varchar2(500);
obj_id number;
begin
v_name:='SEGMENT_ADVISOR';
v_descr:='Segment Advisor Example';
dbms_advisor.create_task (advisor_name => 'Segment Advisor',task_id
=> :id,task_name => v_name,task_desc => v_descr);
-- identify the target object
dbms_advisor.create_object (task_name => v_name,object_type => 'TABLE',attr1 =>
'DBO',attr2 => 'UPT',attr3 => NULL,attr4 => NULL,attr5 => NULL,object_id =>
obj_id);
dbms_advisor.set_task_parameter(task_name => v_name,parameter =>
'recommend_all',value => 'TRUE');
end;

exec dbms_advisor.execute_task('SEGMENT_ADVISOR');

SELECT f.task_name,
f.impact,
o.type AS object_type,
o.attr1 AS schema,
o.attr2 AS object_name,
f.message,
f.more_info
FROM dba_advisor_findings f
JOIN dba_advisor_objects o ON f.object_id = o.object_id AND f.task_name =
o.task_name
WHERE f.task_name IN ('SEGMENT_ADVISOR')
ORDER BY f.task_name, f.impact DESC;

-- Enable row movement.


ALTER TABLE DBO.UPT ENABLE ROW MOVEMENT;

-- Recover space and amend the high water mark (HWM).


ALTER TABLE DBO.UPT SHRINK SPACE;

-- Recover space, but don't amend the high water mark (HWM).
ALTER TABLE scott.emp SHRINK SPACE COMPACT;

-- Recover space for the object and all dependant objects.


ALTER TABLE scott.emp SHRINK SPACE CASCADE;

exec dbms_advisor.delete_task('SEGMENT_ADVISOR');

ORA-10631: SHRINK clause should not be specified for this object


When you try to shrink a table and get this error this is due to the table has
functional based index.
How to find:
Solution:
1-Drop the function-based index.
3- Shrink the table.
4- Recreate the index again on the table.

You might also like