Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: Analyze All Tables Jump to:  
Category: >> Oracle PL/SQL >> Analyze All Tables Bookmark and Share

<< 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;


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 212 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?