Oracle DBMS_STATS获得表的统计信息

  | 转载时请务必以超链接形式标明文章原文链接和作者信息及本版权声明。
原文链接:http://www.liaojl.com/archives/2008/05/oracle-dbms-stats.html

DBMS_STATS包可以获得表的统计信息,在查询前,执行下面过程获得最新统计信息:

exec dbms_stats.gather_schema_stats(ownname=>'LIAOJL',cascade=>true);

还可以指定更多参数:

exec dbms_stats.gather_schema_stats( -
ownname          => 'LIAOJL', -
options          => 'GATHER AUTO', -
estimate_percent => dbms_stats.auto_sample_size, -
method_opt       => 'for all columns size repeat', -
degree           => 15 -
)

查询表行数:

select num_rows from user_tables where table_name='A';

还可以查询以下常用统计信息:

select STATUS,LOGGING from user_tables where table_name='A';
select PCT_FREE,PCT_USED,FREELISTS from user_tables where table_name='A';
select NUM_ROWS,BLOCKS from user_tables where table_name='A';

Leave a comment

Archives

Creative Commons License
This blog is licensed under a Creative Commons License.