Exchange partition with update index

 Exchange none composite-partitioned table

ALTER  TABLE TEST_P EXCHANGE PARTITION P1  WITH TABLE TEST_TEMP UPDATE INDEXES;

 Exchange subparition(composite-partitioned table)

ALTER  TABLE TEST_P2 EXCHANGE SUBPARTITION P1 WITH TABLE  TEST_TEMP UPDATE INDEXES;

 

在使用 EXCHANGE PARTITION with update index可以自动更新索引, 只有Local索引才会失效, 全局索引会被自动更新。

但是也有性能问题要考虑。

Oracle建议全局索引 手动重建 并使用 NOLOGGING 效率会好些。

在实际操作中,需要提前准备的工作:

1.Source 分区表

2. 用于交换的普通表, 表结构月Source分区表保持一致

3.如果是交换到不同用户下的不同的表空间,需要有quota 权限在相关的表空间上

ALTER  USER  Source_user_name  QUOTA UNLIMITED  ON Target_TS_name; 
ALTER  USER  Target_user_name  QUOTA UNLIMITED  ON Source_TS_name; 

Alter table privilege 

4.target 分区表

 

Considerations when Updating Indexes Automatically

The following implications are worth noting when you specify UPDATE INDEXES:

  • The partition DDL statement takes longer to execute, because indexes that were previously marked UNUSABLE are updated. However, you must compare this increase with the time it takes to execute DDL without updating indexes, and then rebuild all indexes. A rule of thumb is that it is faster to update indexes if the size of the partition is less that 5% of the size of the table.

  • The DROPTRUNCATE, and EXCHANGE operations are no longer fast operations. Again, you must compare the time it takes to do the DDL and then rebuild all indexes.

  • When you update a table with a global index:

    • The index is updated in place. The updates to the index are logged, and redo and undo records are generated. In contrast, if you rebuild an entire global index, you can do so in NOLOGGING mode.

    • Rebuilding the entire index manually creates a more efficient index, because it is more compact with better space utilization.

  • The UPDATE INDEXES clause is not supported for index-organized tables. However, the UPDATE GLOBAL INDEXES clause may be used with DROP PARTITIONTRUNCATE PARTITION, and EXCHANGEPARTITION operations to keep the global indexes on index-organized tables usable. For the remaining operations in the above list, global indexes on index-organized tables remain usable. In addition, local index partitions on index-organized tables remain usable after a MOVE PARTITION operation.

https://docs.oracle.com/cd/E11882_01/server.112/e25523/part_admin002.htm#CHDIBFFH

 

The following operations support the UPDATE INDEXES clause:

  • ADD PARTITION | SUBPARTITION

  • COALESCE PARTITION | SUBPARTITION

  • DROP PARTITION | SUBPARTITION

  • EXCHANGE PARTITION | SUBPARTITION

  • MERGE PARTITION | SUBPARTITION

  • MOVE PARTITION | SUBPARTITION

  • SPLIT PARTITION | SUBPARTITION

  • TRUNCATE PARTITION | SUBPARTITION

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值