set line 150
set serveroutput on
declare
obj_empty dbms_stats.ObjectTab;
obj_stale dbms_stats.ObjectTab;
begin
dbms_stats.gather_database_stats(options => 'LIST EMPTY',objlist => obj_empty);
for i in 1..obj_empty.count
loop
dbms_output.put_line('Empty statistics---> Owner: '||obj_empty(i).ownname||' Object name: '||obj_empty(i).objName||'- -Object type: '||obj_empty(i).objType);
end loop;
dbms_stats.gather_database_stats(options => 'LIST STALE',objlist => obj_stale);
for j in 1..obj_stale.count
loop
dbms_output.put_line('Empty statistics---> Owner: '||obj_stale(j).ownname||' Object name: '||obj_stale(j).objName||'- -Object type: '||obj_stale(j).objType);
end loop;
end;
/
输出结果如下:
Empty statistics---> Owner: JASON Object name: TAB_NAME- -Object type: TABLE
Empty statistics---> Owner: JASON Object name: TAB_TEST- -Object type: TABLE
Empty statistics---> Owner: JASON Object name: TEST- -Object type: TABLE
Empty statistics---> Owner: LIUJL Object name: G_TEST- -Object type: TABLE
Empty statistics---> Owner: LIUJL Object name: LJL- -Object type: TABLE
Empty statistics---> Owner: LJL Object name: G_TEST- -Object type: TABLE
Empty statistics---> Owner: LJL Object name: LJL- -Object type: TABLE
Empty statistics---> Owner: SCOTT Object name: AA- -Object type: TABLE
Empty statistics---> Owner: SCOTT Object name: MAGAZINE_ARTICLES- -Object type: TABLE
Empty statistics---> Owner: SYS Object name: AQ$_KUPC$DATAPUMP_QUETAB_1_D- -Object type: TABLE
最后我们可以用DBMS_STATS.GATHER包来收集相应的统计信息
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27192222/viewspace-2851256/ ,如需转载,请注明出处,否则将追究法律责任。