--
exec dbms_stats.create_stat_table(user,'mystat');
--
create table t (id number, name varchar2(30));
begin
for i in 1 .. 10 loop
insert into t (id, name) values(i, 'Steven Jobs');
end loop;
commit;
end;
/
--
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
--
exec dbms_stats.gather_table_stats(user,'T',stattab=>'mystat',statid=>'S001');
--
select table_name, num_rows, last_analyzed from user_tables where table_name='T';
-- mystat ,
select statid, type, n1 num_rows, d1 last_analyzed
from mystat
where statid='S001' and type='T';
-- 5 ,
insert into t select * from t where rownum<=5;
commit;
exec dbms_stats.gather_table_stats(user,'T',stattab=>'mystat',statid=>'S002');
--
select table_name, num_rows, last_analyzed from user_tables where table_name='T';
-- mystat , 10,
select statid, type, n1 num_rows, d1 last_analyzed
from mystat
where statid='S002' and type='T';