prompt
prompt 创建表eoda.t
declare
    num number;
begin
	select count(1) into num from user_tables where table_name = upper('t') ;
	if num = 1 then
		execute immediate 'drop table eoda.t';
	end if;
	execute immediate '
		create table eoda.t
		as
		select * from all_objects
		 where rownum <= 50000
	';
end;
/

prompt
prompt 创建索引eoda.t_idx
declare
	num number;
begin
	select count(1) into num from user_indexes where table_name = upper('t') and index_name = upper('t_idx');
	if num = 1 then
		execute immediate 'drop index eoda.t_idx ';
	end if;
	execute immediate '
		create index eoda.t_idx on
		eoda.t(owner,object_type,object_name)
	';
end;
/

analyze index eoda.t_idx validate structure;

prompt
prompt 创建表eoda.idx_stats
declare
	num number;
begin
	select count(1) into num from user_tables where table_name = upper('idx_stats');
	if num = 1 then
		execute immediate 'drop table eoda.idx_stats';
	end if;
	execute immediate '
		create table eoda.idx_stats
		as
		select ''nocompressed'' what,a.*
		  from index_stats a
	';
end;
/

prompt
prompt 重建索引eoda.idx_stats
declare
	num number;
begin
	select count(1) into num from user_indexes where table_name = upper('t') and index_name = upper('t_idx');
	if num = 1 then
		execute immediate 'drop index eoda.t_idx ';
	end if;
	execute immediate '
		create index eoda.t_idx on
		eoda.t(owner,object_type,object_name )
		compress &1
	';
	execute immediate 'analyze index eoda.t_idx validate structure ';
	insert into eoda.idx_stats
	select 'compress &1',a.*
	  from index_stats a;
end;
/

select what,height,lf_blks,br_blks,btree_space,opt_cmpr_count,opt_cmpr_pctsave
  from eoda.idx_stats
/

select 1974060 * (1-0.28) from dual;
/
