oracle中global_stats列

 今天看Nbear的源码时无意中看到了oracle中global_stats列,但是不知道是什么意思,在网上搜了下资料,把相关信息记录下来,以备以后查询用。

 

从reference上可以查到对于这个列的说明:

global_stats

For partitioned tables, indicates whether statistics were collected for the table as a whole (YES) or were estimated from statistics on underlying partitions and subpartitions (NO)

我们可以根据这一列来判断上一次分析是采用的analyze还是dbms_stats,不仅仅对分区表,非分区表也可以使用

如果表有统计信息,global_stats=NO表明是用analyze分析的,global_stats=YES表明是dbms_stats分析的


SQL> create table xfan(x int);

Table created.

SQL> select global_stats,table_name from user_tables where table_name=’XFAN’;

GLO TABLE_NAME
— ——————————
NO XFAN

SQL> analyze table xfan compute statistics;

Table analyzed.

SQL> select global_stats ,table_name from user_tables where table_name=’XFAN’;

GLO TABLE_NAME
— ——————————
NO XFAN

SQL> exec dbms_stats.gather_table_stats(OWNNAME=> user,tabname=>’xfan’);

PL/SQL procedure successfully completed.

SQL> select global_stats from user_tables where table_name=’XFAN’;

GLO

YES

SQL> create index xfan_idx on xfan(x);

Index created.

SQL> select global_stats ,index_name,last_analyzed from dba_indexes where index_name=’XFAN_IDX’;

GLO INDEX_NAME LAST_ANALYZED
— —————————— —————
NO XFAN_IDX

SQL> analyze index xfan_idx compute statistics;

Index analyzed.

SQL> select global_stats,index_name,last_analyzed from dba_indexes where index_name=’XFAN_IDX’;

GLO INDEX_NAME LAST_ANALYZED
— —————————— —————
NO XFAN_IDX 13-JUN-07

SQL> exec dbms_stats.gather_table_stats(OWNNAME=> user,tabname=>’xfan’,cascade=>true);

PL/SQL procedure successfully completed.

SQL> select global_stats ,index_name,last_analyzed from dba_indexes where index_name=’XFAN_IDX’;

GLO INDEX_NAME LAST_ANALYZED
— —————————— —————
YES XFAN_IDX 13-JUN-07

你可能感兴趣的:(oracle,sql,user,table,reference,statistics)