compute statistics 在创建索引的同时,对表进行分析~
online 允许在创建索引的过程中对表进行操作的~

解决方案 »

  1.   

    刚才在oracle 817 上试了一下,语法没通过,是不是oracle的高版本才支持这样的语法?
    .....
    我所知道的是:compress 4 是索引压缩存储的意思,一般用在组合索引和非唯一性索引上,压缩度必须小于索引中列的数量,也就是说这儿用了compress 4那么索引的列必须在5个以上,但这儿用在单字段上的唯一索引上,根本没空间压缩,比较奇怪,说不定是oracle9或者10g才支持这样的语法吧....compute statistics 应该是精确分析索引。online 我想应该就是联机的意思,这应该是默认值吧。很困惑,请懂的人指点一下!
      

  2.   

    SQL> create table liq as select * from emp;表已创建。SQL> select INDEX_NAME,TABLE_NAME,LAST_ANALYZED from user_indexes;INDEX_NAME                     TABLE_NAME                     LAST_ANALY
    ------------------------------ ------------------------------ ----------
    PK_DEPT                        DEPT
    PK_EMP                         EMPSQL> select TABLE_NAME,LAST_ANALYZED from user_tables;TABLE_NAME                     LAST_ANALY
    ------------------------------ ----------
    BONUS
    DEPT
    EMP
    LIQ
    SALGRADE  1  CREATE UNIQUE INDEX index_liq on liq (empno)
      2  compute statistics
      3* online
    SQL> /索引已创建。SQL> select INDEX_NAME,TABLE_NAME,LAST_ANALYZED from user_indexes;INDEX_NAME                     TABLE_NAME                     LAST_ANALY
    ------------------------------ ------------------------------ ----------
    INDEX_LIQ                      LIQ                            17-7月 -05
    PK_DEPT                        DEPT
    PK_EMP                         EMPSQL> select TABLE_NAME,LAST_ANALYZED from user_tables;TABLE_NAME                     LAST_ANALY
    ------------------------------ ----------
    BONUS
    DEPT
    EMP
    LIQ                            17-7月 -05
    SALGRADESQL>
      

  3.   

    SQL> CREATE UNIQUE INDEX COMPRESS_UNIQUE_EMP ON liq(ENAME, EMPNO) COMPRESS 1
      2  compute statistics online;索引已创建。
    SQL> select INDEX_NAME,TABLE_NAME,LAST_ANALYZED from user_indexes;INDEX_NAME                     TABLE_NAME                     LAST_ANALY
    ------------------------------ ------------------------------ ----------
    COMPRESS_UNIQUE_EMP            LIQ                            17-7月 -05
    INDEX_LIQ                      LIQ                            17-7月 -05
    PK_DEPT                        DEPT
    PK_EMP                         EMPSQL> CREATE UNIQUE INDEX COMPRESS_UNIQUE_EMP2 ON liq(ENAME, EMPNO,job) COMPRESS
    2;索引已创建。
    SQL> alter INDEX COMPRESS_UNIQUE_EMP2  rebuild  COMPRESS 1;索引已更改。
    SQL> alter INDEX COMPRESS_UNIQUE_EMP2  rebuild  COMPRESS 3;
    alter INDEX COMPRESS_UNIQUE_EMP2  rebuild  COMPRESS 3
                                                        *
    ERROR 位于第 1 行:
    ORA-25194: 无效的 COMPRESS 前缀长度值
    SQL> alter INDEX COMPRESS_UNIQUE_EMP2  rebuild  COMPRESS 2;索引已更改。
    How To Use Compress Indexes: ============================  Beginning with Oracle8i, there is a new index COMPRESS option to enable key compression which eliminates repeated occurence of key column values and may  substantially reduce storage.  You can use this COMPRESS option for btree indexes and IOT.   The compression is realized by splitting the index key in two parts: the prefix and suffix part.  Use integer to specify the prefix length (number of prefix  columns to compress).  If you indicate the COMPRESS option without range,  Oracle will take all the columns minus the last one for compression.  The maximum columns which may be choosen for prefix may be:    - all the columns if the index is non unique.  - all the columns minus one if the index is unique.  The prefix part is choosen as a common part, whereas the suffix is considered  as a unique key.  Each prefix part will then shared between all the suffix  parts.  It offers the means to load more keys in each block, thus increases  performance with access by index by limiting the number of accessed blocks. The key compression is made each block by each block, and only at the leaf  level.  On the contrary, the performance by index scan will decrease because  Oracle must translate the <prefix, suffix> part in corresponding key.  Oracle compresses only single-column indexes that are non unique or unique  indexes of at least two columns.   Restriction:  You cannot specifiy COMPRESS for a bitmap index. 
      

  4.   

    SQL> CREATE UNIQUE INDEX COMPRESS_UNIQUE_EMP ON liq(ENAME, EMPNO) COMPRESS 1
      2  compute statistics online;索引已创建。
    SQL> select INDEX_NAME,TABLE_NAME,LAST_ANALYZED from user_indexes;INDEX_NAME                     TABLE_NAME                     LAST_ANALY
    ------------------------------ ------------------------------ ----------
    COMPRESS_UNIQUE_EMP            LIQ                            17-7月 -05
    INDEX_LIQ                      LIQ                            17-7月 -05
    PK_DEPT                        DEPT
    PK_EMP                         EMPSQL> CREATE UNIQUE INDEX COMPRESS_UNIQUE_EMP2 ON liq(ENAME, EMPNO,job) COMPRESS
    2;索引已创建。
    SQL> alter INDEX COMPRESS_UNIQUE_EMP2  rebuild  COMPRESS 1;索引已更改。
    SQL> alter INDEX COMPRESS_UNIQUE_EMP2  rebuild  COMPRESS 3;
    alter INDEX COMPRESS_UNIQUE_EMP2  rebuild  COMPRESS 3
                                                        *
    ERROR 位于第 1 行:
    ORA-25194: 无效的 COMPRESS 前缀长度值
    SQL> alter INDEX COMPRESS_UNIQUE_EMP2  rebuild  COMPRESS 2;索引已更改。
    How To Use Compress Indexes: ============================  Beginning with Oracle8i, there is a new index COMPRESS option to enable key compression which eliminates repeated occurence of key column values and may  substantially reduce storage.  You can use this COMPRESS option for btree indexes and IOT.   The compression is realized by splitting the index key in two parts: the prefix and suffix part.  Use integer to specify the prefix length (number of prefix  columns to compress).  If you indicate the COMPRESS option without range,  Oracle will take all the columns minus the last one for compression.  The maximum columns which may be choosen for prefix may be:    - all the columns if the index is non unique.  - all the columns minus one if the index is unique.  The prefix part is choosen as a common part, whereas the suffix is considered  as a unique key.  Each prefix part will then shared between all the suffix  parts.  It offers the means to load more keys in each block, thus increases  performance with access by index by limiting the number of accessed blocks. The key compression is made each block by each block, and only at the leaf  level.  On the contrary, the performance by index scan will decrease because  Oracle must translate the <prefix, suffix> part in corresponding key.  Oracle compresses only single-column indexes that are non unique or unique  indexes of at least two columns.   Restriction:  You cannot specifiy COMPRESS for a bitmap index.