Quick Search:
 
 Oracle PL/SQL: Analyze All Tables Jump to:  
Category: >> Oracle PL/SQL >> Analyze All Tables  

<< lastnext >>

Snippet Name: Analyze All Tables

Description: This procedure will analyze and estimate statistics for all the tables in the user's schema.

Comment: (none)

Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: February 27th, 2009

SET serveroutput ON size 1000000
DECLARE
 cursor_id INTEGER;
 v_tablenames VARCHAR2(30);
 v_counter NUMBER:=0;
CURSOR rec_finder IS
SELECT table_name
FROM user_tables;
 
BEGIN
OPEN rec_finder;
  LOOP
  FETCH rec_getter INTO v_tablenames;
  EXIT WHEN rec_finder%notfound;
   cursor_id:=DBMS_SQL.OPEN_CURSOR;
   DBMS_SQL.PARSE (cursor_id, 'ANALYZE TABLE '||v_tablenames||' estimate stats',DBMS_SQL.NATIVE);
   DBMS_SQL.CLOSE_CURSOR (cursor_id);
  v_counter:= v_counter + 1;
  DBMS_OUTPUT.PUT_LINE (' Processing Table: '||v_tablenames);
END LOOP;
DBMS_OUTPUT.PUT_LINE ('Tables analyzed:'||v_counter.); 
CLOSE rec_finder;
END;


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org