analyze index t_idx validate structure : Analyze « SQL Plus « Oracle PL / SQL






analyze index t_idx validate structure

  

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>

   
    
  








Related examples in the same category

1.analyze materialized view
2.analyze index
3.Analyze table with primary key and foreign key
4.Demonstrate IN versus EXISTS performance
5.analyze table tableName compute statistics for table, for all indexes, for all indexed columns;
6.ANALYZE TABLE employee COMPUTE STATISTICS
7.analyze index validate structure
8.analyze table compute statistics
9.analyze table compute statistics for all indexes
10.analyze table compute statistics for a table with two indexes
11.create or replace outline and analyze table compute statistics
12.Analyze a table with/without index
13.Anayze all objects in the APPOWNER schema.
14.Analyze index on varchar2 value and date type value
15.analyze and autotrace full outer join and union
16.analyze and autotrace single column key and multi-column key
17.analyze and autotrace table with primary key
18.analyze table TABLENAME compute statistics;
19.analyze table after creating index
20.analyze table estimate statistics
21.analyze table students compute statistics
22.analyze table t compute statistics for table for columns id;
23.analyze table t compute statistics for table, for all indexes, for all indexed columns