Important alert: (current site time 7/15/2013 7:21:31 PM EDT)
 

VB icon

Analyzer

Email
Submitted on: 4/26/2002 9:07:53 PM
By: Ron Santillano  
Level: Intermediate
User Rating: By 1 Users
Compatibility: Oracle
Views: 11481
 
     This procedure will Analyze & Estimate Statistics for all tables in the users schema. Only takes 3-10 minutes to run. It can easily be edited to Compute Statistics or specific number of rows in each table.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
--**************************************
-- Name: Analyzer
-- Description:This procedure will Analyze & Estimate Statistics for all tables in the users schema. Only takes 3-10 minutes to run. It can easily be edited to Compute Statistics or specific number of rows in each table.
-- By: Ron Santillano
--
-- Assumes:This has been tested on Oracle 7.3.4 thru 8.1.7
--
--This code is copyrighted and has-- limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=456&lngWId=5--for details.--**************************************

---------------------------------------------------------------------
--This script will analyze 1024 records in each table the user owns--
--By Ron Santillano 3/13/2002--
---------------------------------------------------------------------
set serveroutput on size 1000000
DECLARE
 cursor_id Integer;
 v_tablenames varchar2(30);
 v_counter number:=0;
CURSOR rec_getter IS
select table_name
from user_tables;
BEGIN
 Open rec_getter;
 LOOP
fetch rec_getter INTO v_tablenames;
exit when rec_getter%notfound;
 cursor_id:=DBMS_SQL.OPEN_CURSOR;
 --estimate statistics can be changed to compute statistics but will take much longer
 --to run since compute statistics will go through every record in each table 
 DBMS_SQL.PARSE (cursor_id, 'ANALYZE TABLE '||v_tablenames||' estimate statistics',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 ('The procedure has processed '||v_counter||' tables'); 
 Close rec_getter;
end;
/


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

10/22/2002 7:25:33 PM

Where can I get the output statistics after running this code?
(If this comment was disrespectful, please report it.)

 
12/20/2006 10:52:09 AMAnthony Russo

What is the command to compute statistics?
(If this comment was disrespectful, please report it.)

 
5/31/2007 12:04:38 PMTom

Anthony Russo
Replace Estimate with Compute.
Simple as that.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.