【TUNE_ORACLE】查看表,列和索引的统计信息SQL参考

实验环境

搭建平台:VMware Workstation

OS:RHEL 6.10

Grid&DB:Oracle 11.2.0.4


SQL参考

--单表的统计信息

select owner, table_name, num_rows, blocks, avg_row_len

  from dba_tables

 where owner = 'aaa'

   and table_name = 'bbb';


--表和列的统计信息

select a.column_name,

       b.num_rows,

       a.num_nulls,

       a.num_distinct cardinality,

       round(a.num_distinct / b.num_rows * 100, 2) selectivity,

       a.hisogram,

       a.num_buckets

  from dba_tab_col_statistics a, dba_tables b

 where a.owner = b.owner

   and a.table_name = b.table_name

   and a.owner = 'aaa'

   and a.table_name = 'bbb';


--索引的统计信息

select blevel, leaf_blocks, clustering_factor, status

  from dba_indexes

 where owner = 'aaa';

   and index_name = 'bbb';


请使用浏览器的分享功能分享到微信等