|
-
You can get chained rows report by running following stored proc.
CREATE OR REPLACE PROCEDURE RPT_CHAINED_ROW (v_schema in char)
IS
num_chained_rows NUMBER;
target_table VARCHAR2(30);
statement VARCHAR2(256);
my_cursor INTEGER;
ignore INTEGER;
-- Define Cursor to LOOP Thru each user table
CURSOR all_tables_cur IS
SELECT table_name
FROM dba_tables
where owner = v_schema;
BEGIN
-- Increase Buffer Size
dbms_output.enable(1000000);
-- Print Title
dbms_output.put_line(chr(10));
dbms_output.put_line(chr(10)||'Chained Row(s) on User Tables for '||v_schema||' schema');
dbms_output.put_line('----------------------------------------');
-- Print Header
DBMS_OUTPUT.PUT_LINE(RPAD('Table Name',20)||
'Chained Row(s)');
dbms_output.put_line('----------------------------------------');
DELETE
FROM CHAINED_ROWS;
FOR t_name IN all_tables_cur
LOOP
target_table := RTRIM(t_name.table_name);
-- Define SELECT statement for dynamic query
statement := 'ANALYZE TABLE ' ||v_schema||'.'||target_table ||
' LIST CHAINED ROWS';
my_cursor := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(my_cursor,statement,DBMS_SQL.V7);
ignore := DBMS_SQL.EXECUTE(my_cursor);
DBMS_SQL.CLOSE_CURSOR(my_cursor);
SELECT COUNT(*)
INTO num_chained_rows
FROM CHAINED_ROWS
WHERE table_name = target_table;
DBMS_OUTPUT.PUT_LINE(RPAD(target_table,20)||
num_chained_rows);
END LOOP;
END;
/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|