Solved

Table Statistics

Posted on 2001-06-18
10
1,419 Views
Last Modified: 2008-03-17
Table Statistics

I am a newbie to Oracle.

I'm selecting all tables from my schema with owner 'PRASHANT'.
like this
          SELECT
               TABLE_NAME
          FROM
               ALL_TABLES
          WHERE
               owner = 'PRASHANT';

I need a PL/SQL code to process each table..estimate statistics and write statistics report in
another table.

Thanks in advance
0
Comment
Question by:prashant_n_mhatre
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 2

Expert Comment

by:stmontgo
ID: 6202960
dba_tab_columns keeps statistics info, is that what you are looking for?

u can use desc dbms_utility.analyze_schema to analyze all objects in a given schema.


SQL> desc dbms_utility.analyze_schema;
PROCEDURE dbms_utility.analyze_schema
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 SCHEMA                         VARCHAR2                IN
 METHOD                         VARCHAR2                IN
 ESTIMATE_ROWS                  NUMBER                  IN     DEFAULT
 ESTIMATE_PERCENT               NUMBER                  IN     DEFAULT
 METHOD_OPT                     VARCHAR2                IN     DEFAULT
0
 
LVL 9

Expert Comment

by:dbalaski
ID: 6204949
Depending upon your version --

While dbms_utility.analyze_schema  is good,   oracle recommends that you use the DBMS_STATS package for collecting statistics -- especially for use with the COST BASED OPTIMIZER  
(init.ora  parameter     optimizer=    set to either  CHOOSE,  FIRST_ROWS,  ALL_ROWS)...

This package will populate the base tables behind  the ALL_TABLES/DBA_TABLES views (and others as well)...     It's speed is much faster than the dbms_utility.analyze_schema  

You can read about it in the Oracle8i Supplied PL/SQL Packages Reference Release 2 (8.1.6)
chapter 56  DBMS_STATS  
as well as a few other manuals..

hope this helps,
dBalaski

0
 
LVL 4

Accepted Solution

by:
dda earned 30 total points
ID: 6204967
Also consider this SQL*Plus (not a PL/SQL) example:

set pagesize 0
set feedback off
spool an.sql
select 'analyze table ' || table_name || ' compute statistics;'
   from
      all_tables
   where
      owner = 'PRASHANT';
spool off
@@an.sql
0
 
LVL 4

Author Comment

by:prashant_n_mhatre
ID: 6206913
I have already figured out a solution. It is exactly similar to what 'dda' has proposed.

'dbms_utility.analyze_schema' doesn't work. It simply gives error.


0
 
LVL 4

Expert Comment

by:dda
ID: 6208239
Hmm.. Would you tell us what eror are you getting?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 4

Author Comment

by:prashant_n_mhatre
ID: 6238161
sorry for not getting back for a long..

It says
SP2-0734: unknown command beginning "dbms_utili..."
0
 
LVL 4

Expert Comment

by:dda
ID: 6240547
Add 'exec' before 'dbms_utility':

SQL>exec dbms_utility.analyze_schema(....)
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6360905
Please update this question if more is needed, or award th expert who helped you.  If a point split award is in order, let us know details.

Thank you,
Moondancer
Community Support Moderator @ Experts Exchange
0
 
LVL 4

Author Comment

by:prashant_n_mhatre
ID: 6360988
Please split points like:

dda : 30
stmontgo : 20
dbalaski : 20

Thanks Everybody !!!
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6361156
Point split transactions have now been completed to award experts as follows.  Please comment in your respective
link below to complete.

dda : 30   Awarded in the primary question
Points for  stmontgo : 20   http://www.experts-exchange.com/jsp/qManageQuestion.jsp?qid=20164785
Points for  dbalaski : 20    http://www.experts-exchange.com/jsp/qManageQuestion.jsp?qid=20164787

Thank you,

Mondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now