【问题标题】:ORACLE EXCHANGE PARTITION and PARTITION INDEXESORACLE EXCHANGE 分区和分区索引
【发布时间】:2016-11-07 01:08:14
【问题描述】:

为了压缩单个分区中的数据,我使用了以下方法:

-- I create a table with the same structure of the ORIGINAL TABLE, but
-- on a new tablespace (NEW_TBS_DATA)

CREATE TABLE AUXILIARY_TABLE TABLESPACE NEW_TBS_DATA AS 
SELECT * FROM ORIGINAL_TABLE WHERE 1=0

-- I create the index on the AUXILIARY_TABLE, on a new tablespace 
-- for indexes (NEW_TBS_IDX)

CREATE   INDEX I_1 ON AUXILIARY_TABLE( START_DATE) TABLESPACE NEW_TBS_IDX
CREATE   INDEX I_2 ON AUXILIARY_TABLE( ID_FILE) TABLESPACE NEW_TBS_IDX
CREATE   INDEX I_3 ON AUXILIARY_TABLE( DESCRIPTION) TABLESPACE NEW_TBS_IDX
CREATE   INDEX I_4 ON AUXILIARY_TABLE( ZIP_CODE) TABLESPACE NEW_TBS_IDX
CREATE   INDEX I_5 ON AUXILIARY_TABLE( BH_TRAFFIC) TABLESPACE NEW_TBS_IDX 

-- I move data from partition 20160529 to auxiliary_table

ALTER TABLE ORIGINAL_TABLE EXCHANGE PARTITION PARTITION_20160529 WITH TABLE AUXILIARY_TABLE INCLUDING INDEXES WITHOUT VALIDATION

-- I compress data using the new tablespace NEW_TBS_DATA on auxiliary_table

ALTER TABLE AUXILIARY_TABLE  MOVE  TABLESPACE NEW_TBS_DATA PARALLEL 4 COMPRESS

-- I move the data back to the original table, with the same exchange statement:

ALTER TABLE ORIGINAL_TABLE EXCHANGE PARTITION PARTITION_20160529 WITH TABLE AUXILIARY_TABLE including indexes without validation

-- I drop the auxiliary_table

DROP TABLE AUXILIARY_TABLE CASCADE CONSTRAINTS PURGE

为什么在进程结束时,分区 INDEXES 位于旧表空间而不是新表空间 (NEW_TBS_IDX) 上?

【问题讨论】:

    标签: oracle indexing partitioning


    【解决方案1】:

    “包括索引”部分仅对本地索引有效。看 https://docs.oracle.com/cd/E11882_01/server.112/e25523/part_admin002.htm 部分(交换分区)

    【讨论】:

    • 我该怎么做才能意识到在第二个 EXCHANGE PARTITION 语句之后,索引位于 NEW_TBS_IDX 而不是 OLD_TBS_IDX 上?
    猜你喜欢
    • 2013-06-02
    • 1970-01-01
    • 2018-09-24
    • 1970-01-01
    • 2017-04-22
    • 1970-01-01
    • 2019-11-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多