1 按用户收集统计信息
exec dbms_stats.gather_schema_stats(ownname=>'htuser',estimate_percent=>dbms_stats.auto_sample_size,
method_opt=>'for all columns size auto',degree=>8,cascade=>true);
2 按表收集统计信息
exec dbms_stats.gather_table_stats(ownname=>'htuser',tabname=>'ht_test_fy', estimate_percent=>100,method_opt=>'for all columns size repeat',no_invalidate=>false,degree=>8,cascade=>true);
3 查看表的统计信息
select t.OWNER, t.TABLE_NAME, t.NUM_ROWS, t.LAST_ANALYZED, t.PARTITIONED
from dba_tables t where t.TABLE_NAME in ('a','b', 'c')
如果上次收集统计信息时间在1周以前,或者num_rows和当前表中记录数差距较大,应对该表新收集统计信息:
4 索引的统计信息
select owner,table_name,index_name,last_analyzed from dba_indexes where table_name ='&table_name';
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25846553/viewspace-3099540/ ,如需转载,请注明出处,否则将追究法律责任。