----创建表
SQL> create table test as (select * from all_objects);
Table created.
SQL> insert into test (select * from all_objects);
38167 rows created.
SQL> commit;
Commit complete.
----创建索引
SQL> create index ind_test on test (object_name);
Index created.
-------表还没有统计信息
SQL> select table_name,last_analyzed from user_tables where table_name='TEST';
TABLE_NAME LAST_ANALYZED
------------------------------------------------------------ --------------
TEST
-------索引的统计信息是新创建的时候的:2010年5月30日18:59:46
SQL> select index_name,to_char(last_analyzed,'yyyymmddHH24MISS') from user_indexes where index_name='IND_TEST';
INDEX_NAME TO_CHAR(LAST_ANALYZED,'YYYYM
--------------- ----------------------------
IND_TEST 20100530185946
SQL> select to_char(sysdate,'yyyymmddHH24MISS') from dual;
TO_CHAR(SYSDATE,'YYYYMMDDHH2
----------------------------
20100530190139
--------执行表分析
SQL> exec dbms_stats.gather_table_stats(ownname => 'charis',tabname => 'test');
PL/SQL procedure successfully completed.
--------更新了表的统计信息
SQL> select table_name,to_char(last_analyzed,'yyyymmddHH24MISS') from user_tables where table_name='TEST';
TABLE_NAME TO_CHAR(LAST_ANALYZED,'YYYYM
-------------------- ----------------------------
TEST 20100530190256
--------更新了索引的统计信息
SQL> select index_name,to_char(last_analyzed,'yyyymmddHH24MISS') from user_indexes where index_name='IND_TEST';
INDEX_NAME TO_CHAR(LAST_ANALYZED,'YYYYM
--------------- ----------------------------
IND_TEST 20100530190256
SQL> select count(1) from test;
COUNT(1)
----------
76334
SQL>
[@more@]来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23850820/viewspace-1034366/ ,如需转载,请注明出处,否则将追究法律责任。