ITPub博客

首页 > 数据库 > Oracle > 统计信息收集

统计信息收集

原创 Oracle 作者:long_small 时间:2025-11-03 14:11:56 0 删除 编辑

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/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: oracle expdp
请登录后发表评论 登录
全部评论
吕生龙,现就职于IBM,db2 dba,oracle 10G OCP

注册时间:2020-04-07

  • 博文量
    64
  • 访问量
    66984