ORACLE 12.2新特性-在線將非分區錶轉換成分區表

通過在ALTER table SQL語句中添加MODIFY子句,可以將非分區錶轉換爲分區表。

此外,還可以指定關鍵字ONLINE,在轉換過程中啓用併發DML操作。

語法如下:

ALTER TABLE table_name MODIFY table_partitioning_clauses
  [ filter_condition ]
  [ ONLINE ]
  [ UPDATE INDEXES [ ( index { local_partitioned_index | global_partitioned_index | GLOBAL }
                     [, index { local_partitioned_index | global_partitioned_index | GLOBAL } ]... )
                   ]
  ]

下面是ALTER TABLE語句的一個示例,該語句使用ONLINE關鍵字將聯機轉換爲分區表。

示例---Using the MODIFY clause of ALTER TABLE to convert online to a partitioned table

ALTER TABLE employees_convert MODIFY
  PARTITION BY RANGE (employee_id) INTERVAL (100)
  ( PARTITION P1 VALUES LESS THAN (100),
    PARTITION P2 VALUES LESS THAN (500)
   ) ONLINE
  UPDATE INDEXES
 ( IDX1_SALARY LOCAL,
   IDX2_EMP_ID GLOBAL PARTITION BY RANGE (employee_id)
  ( PARTITION IP1 VALUES LESS THAN (MAXVALUE))
 );

使用UPDATE INDEX子句時的注意事項:

When using the UPDATE INDEXES clause, note the following.

  • This clause can be used to change the partitioning state of indexes and storage properties of the indexes being converted.

  • The specification of the UPDATE INDEXES clause is optional.

    Indexes are maintained both for the online and offline conversion to a partitioned table.

  • This clause cannot change the columns on which the original list of indexes are defined.

  • This clause cannot change the uniqueness property of the index or any other index property.

  • If you do not specify the tablespace for any of the indexes, then the following tablespace defaults apply.

    • Local indexes after the conversion collocate with the table partition.

    • Global indexes after the conversion reside in the same tablespace of the original global index on the non-partitioned table.

  • If you do not specify the INDEXES clause or the INDEXES clause does not specify all the indexes on the original non-partitioned table, then the following default behavior applies for all unspecified indexes.

    • Global partitioned indexes remain the same and retain the original partitioning shape.

    • Non-prefixed indexes become global nonpartitioned indexes.

    • Prefixed indexes are converted to local partitioned indexes.

      Prefixed means that the partition key columns are included in the index definition, but the index definition is not limited to including the partitioning keys only.

    • Bitmap indexes become local partitioned indexes, regardless whether they are prefixed or not.

      Bitmap indexes must always be local partitioned indexes.

  • The conversion operation cannot be performed if there are domain indexes.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章