analyze index t_idx validate structure : analyze « SQL PLUS Session Environment « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> create table t ( x int, y int );

Table created.

SQL>
SQL> create unique index t_idx on t(x,y);

Index created.

SQL>
SQL> insert into t values ( 1, 1 );

1 row created.

SQL> insert into t values ( 1, NULL );

1 row created.

SQL> insert into t values ( NULL, 1 );

1 row created.

SQL> insert into t values ( NULL, NULL );

1 row created.

SQL>
SQL> analyze index t_idx validate structure;

Index analyzed.

SQL>
SQL> select name, lf_rows from index_stats;

NAME                              LF_ROWS
------------------------------ ----------
T_IDX                                   3

SQL>
SQL> insert into t values ( NULL, NULL );

1 row created.

SQL> insert into t values ( NULL, 1 );
insert into t values ( NULL, 1 )
*
ERROR at line 1:
ORA-00001: unique constraint (JAVA2S.T_IDX) violated


SQL> insert into t values ( 1, NULL );
insert into t values ( 1, NULL )
*
ERROR at line 1:
ORA-00001: unique constraint (JAVA2S.T_IDX) violated


SQL>
SQL> select x, y, count(*) from t group by x,y having count(*) > 1;

         X          Y   COUNT(*)
---------- ---------- ----------
                               2

SQL>
SQL> drop table t;

Table dropped.

SQL>
SQL> create table t ( x int, y int NOT NULL );

Table created.

SQL> create unique index t_idx on t(x,y);

Index created.

SQL>
SQL> insert into t values ( 1, 1 );

1 row created.

SQL> insert into t values ( NULL, 1 );

1 row created.

SQL>
SQL> begin
  2    dbms_stats.gather_table_stats(user,'T');
  3  end;
  4  /

PL/SQL procedure successfully completed.

SQL> set autotrace on
SQL>
SQL> select * from t where x is null;

         X          Y
---------- ----------
                    1


Execution Plan
----------------------------------------------------------
Plan hash value: 2946670127

----------------------------------------------------------
| Id  | Operation        | Name  | Rows  | Bytes | Cost  |
----------------------------------------------------------
|   0 | SELECT STATEMENT |       |     1 |     5 |     1 |
|*  1 |  INDEX RANGE SCAN| T_IDX |     1 |     5 |     1 |
----------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - access("X" IS NULL)

Note
-----
   - cpu costing is off (consider enabling it)


Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
          1  consistent gets
          0  physical reads
          0  redo size
        456  bytes sent via SQL*Net to client
        380  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

SQL>
SQL> set autotrace off
SQL>
SQL> drop table t;

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