analyze table compute statistics : analyze « SQL PLUS Session Environment « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » SQL PLUS Session Environment » analyze 
29. 33. 1. analyze table compute statistics
SQL>
SQL>
SQL> create table myTable1 as select from all_objects where rownum < 50;

Table created.

SQL> create table myTable2 as select from all_objects where rownum <= 50;

Table created.

SQL>
SQL> alter table myTable1 add constraint myTable1_pk primary key(object_id);

Table altered.

SQL> alter table myTable2 add constraint myTable2_pk primary key(object_id);

Table altered.

SQL>
SQL> analyze table myTable1 compute statistics
  2  for table for all indexes for all indexed columns;

Table analyzed.

SQL>
SQL> analyze table myTable2 compute statistics
  2  for table for all indexes for all indexed columns;

Table analyzed.

SQL>
SQL> create or replace function get_datap_object_id in number return varchar2
  2  is
  3      l_object_name myTable2.object_name%type;
  4  begin
  5      select object_name into l_object_name
  6        from myTable2
  7       where object_id = p_object_id;
  8      return l_object_name;
  9  exception
 10      when no_data_found then
 11          return NULL;
 12  end;
 13  /

Function created.

SQL>
SQL> select a.object_id, a.object_name oname1, b.object_name oname2
  2    from myTable1 a, myTable2 b
  3   where a.object_id = b.object_id(+);

 OBJECT_ID ONAME1                         ONAME2
---------- ------------------------------ ------------------------------
        20 ICOL$                          ICOL$
        44 I_USER1                        I_USER1
        28 CON$                           CON$
        15 UNDO$                          UNDO$
        29 C_COBJ#                        C_COBJ#
         I_OBJ#                         I_OBJ#
        25 PROXY_ROLE_DATA$               PROXY_ROLE_DATA$
        39 I_IND1                         I_IND1
        51 I_CDEF2                        I_CDEF2
        26 I_PROXY_ROLE_DATA$_1           I_PROXY_ROLE_DATA$_1
        17 FILE$                          FILE$

 OBJECT_ID ONAME1                         ONAME2
---------- ------------------------------ ------------------------------
        13 UET$                           UET$
         I_FILE#_BLOCK#                 I_FILE#_BLOCK#
        41 I_FILE1                        I_FILE1
        48 I_CON1                         I_CON1
        38 I_OBJ3                         I_OBJ3
         I_TS#                          I_TS#
        53 I_CDEF4                        I_CDEF4
        19 IND$                           IND$
        14 SEG$                           SEG$
         C_TS#                          C_TS#
        42 I_FILE2                        I_FILE2

 OBJECT_ID ONAME1                         ONAME2
---------- ------------------------------ ------------------------------
        21 COL$                           COL$
        43 I_TS1                          I_TS1
        35 I_UNDO2                        I_UNDO2
         CLU$                           CLU$
        23 PROXY_DATA$                    PROXY_DATA$
        24 I_PROXY_DATA$                  I_PROXY_DATA$
        36 I_OBJ1                         I_OBJ1
        46 I_COL2                         I_COL2
        37 I_OBJ2                         I_OBJ2
        54 I_CCOL1                        I_CCOL1
        16 TS$                            TS$

 OBJECT_ID ONAME1                         ONAME2
---------- ------------------------------ ------------------------------
         C_FILE#_BLOCK#                 C_FILE#_BLOCK#
        10 C_USER#                        C_USER#
        34 I_UNDO1                        I_UNDO1
        56 BOOTSTRAP$                     BOOTSTRAP$
        12 FET$                           FET$
        33 I_TAB1                         I_TAB1
        32 CCOL$                          CCOL$
        22 USER$                          USER$
        49 I_CON2                         I_CON2
        30 I_COBJ#                        I_COBJ#
        18 OBJ$                           OBJ$

 OBJECT_ID ONAME1                         ONAME2
---------- ------------------------------ ------------------------------
        47 I_COL3                         I_COL3
         C_OBJ#                         C_OBJ#
         TAB$                           TAB$
        31 CDEF$                          CDEF$
        50 I_CDEF1                        I_CDEF1

49 rows selected.

SQL>
SQL> select object_id, object_name oname1, get_data(object_idoname2
  2    from myTable1;

 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        20 ICOL$
ICOL$

        44 I_USER1
I_USER1

        28 CON$
CON$


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        15 UNDO$
UNDO$

        29 C_COBJ#
C_COBJ#

         I_OBJ#
I_OBJ#


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        25 PROXY_ROLE_DATA$
PROXY_ROLE_DATA$

        39 I_IND1
I_IND1

        51 I_CDEF2
I_CDEF2


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        26 I_PROXY_ROLE_DATA$_1
I_PROXY_ROLE_DATA$_1

        17 FILE$
FILE$

        13 UET$
UET$


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
         I_FILE#_BLOCK#
I_FILE#_BLOCK#

        41 I_FILE1
I_FILE1

        48 I_CON1
I_CON1


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        38 I_OBJ3
I_OBJ3

         I_TS#
I_TS#

        53 I_CDEF4
I_CDEF4


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        19 IND$
IND$

        14 SEG$
SEG$

         C_TS#
C_TS#


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        42 I_FILE2
I_FILE2

        21 COL$
COL$

        43 I_TS1
I_TS1


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        35 I_UNDO2
I_UNDO2

         CLU$
CLU$

        23 PROXY_DATA$
PROXY_DATA$


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        24 I_PROXY_DATA$
I_PROXY_DATA$

        36 I_OBJ1
I_OBJ1

        46 I_COL2
I_COL2


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        37 I_OBJ2
I_OBJ2

        54 I_CCOL1
I_CCOL1

        16 TS$
TS$


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
         C_FILE#_BLOCK#
C_FILE#_BLOCK#

        10 C_USER#
C_USER#

        34 I_UNDO1
I_UNDO1


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        56 BOOTSTRAP$
BOOTSTRAP$

        12 FET$
FET$

        33 I_TAB1
I_TAB1


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        32 CCOL$
CCOL$

        22 USER$
USER$

        49 I_CON2
I_CON2


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        30 I_COBJ#
I_COBJ#

        18 OBJ$
OBJ$

        47 I_COL3
I_COL3


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
         C_OBJ#
C_OBJ#

         TAB$
TAB$

        31 CDEF$
CDEF$


 OBJECT_ID ONAME1
---------- ------------------------------
ONAME2
--------------------------------------------------------------------------------
        50 I_CDEF1
I_CDEF1


49 rows selected.

SQL>
SQL> begin
  2
  3      for x in select a.object_id,
  4                        a.object_name oname1,
  5                        b.object_name oname2
  6                   from myTable1 a, myTable2 b
  7                  where a.object_id = b.object_id(+) )
  8      loop
  9          null;
 10      end loop;
 11
 12      for x in select object_id,
 13                        object_name oname1,
 14                        get_data(object_idoname2
 15                   from myTable1 )
 16      loop
 17          null;
 18      end loop;
 19
 20  end;
 21  /

PL/SQL procedure successfully completed.

SQL>
SQL> drop table myTable1;

Table dropped.

SQL> drop table myTable2;

Table dropped.

SQL>
29. 33. analyze
29. 33. 1. analyze table compute statistics
29. 33. 2. analyze compute statistics on table with index
29. 33. 3. Analyze table with user defined column type
29. 33. 4. analyze table compute statistics for table for all indexes for all indexed columns
29. 33. 5. analyze and autotrace full outer join and union
29. 33. 6. analyze and autotrace single column key and multi-column key
29. 33. 7. analyze and autotrace table with primary key
29. 33. 8. analyze index t_idx validate structure
29. 33. 9. analyze table TABLENAME compute statistics;
29. 33. 10. analyze table after creating index
29. 33. 11. analyze table estimate statistics
29. 33. 12. analyze table students compute statistics
29. 33. 13. analyze table t compute statistics for table for columns id;
29. 33. 14. analyze table t compute statistics for table, for all indexes, for all indexed columns
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.