PLSQL_统计信息系列02_统计信息的对象

20150505 Created By BaoXinjian

一摘要


有三种类型的对象统计信息: 表统计、列统计和索引统计

对每个烈性来说,有有紫烈,表或索引级别的统计,分区级别的统计和子分区级别的统计

1. 统计信息类型

(1). 表的统计信息

(2). 列的统计信息

(3). 直方图

(4). 扩展的统计信息

(5). 索引的统计信息

2. 建立测试案例

--创建表
create table t
as
select rownum as id,
       round(dbms_random.normal*1000) as val1,
       100+round(ln(rownum/3.25+2)) as val2,
       100+round(ln(rownum/3.25+2)) as val3,
       dbms_random.string('p',250) as pad
from all_objects
where rownum <= 1000
order by dbms_random.value;

update t set val1 = null where val1 < 0;

alter table t add constraint t_pk primary key (id);

create index t_val1_i on t(val1);

create index t_val2_i on t(val2);

--对表进行分析
begin
dbms_stats.gather_table_stats(
       ownname          => user,
       tabname          => 'T',
       estimate_percent =>100,
       method_opt       => 'for all columns size skewonly',
       cascade          => TRUE
);
end;

 

二、表的统计信息


 

 

select num_rows, blocks, empty_blocks, avg_space, chain_cnt, avg_row_len
  from dba_tab_statistics
 where table_name = 'T'

 

 

 

 

 

三、列的统计信息


 

 

 

 

四、直方图


 

 

 

 

五、扩展的统计信息


 

 

 

 

六、索引的统计信息


 

 

 

 

 

 

 

 

Thanks and Regards

posted on 2014-01-09 10:42  东方瀚海  阅读(637)  评论(0编辑  收藏  举报