用dbms_stats的备份表,备份统计信息

来源:互联网 发布:js中创建字符串对象 编辑:程序博客网 时间:2024/05/18 13:31
-- 创建统计备分表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_analyzedfrom mystatwhere 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_analyzedfrom mystatwhere statid='S002' and type='T';

原创粉丝点击