Di Oracle Database 18c, sekarang kita mengubah strategi partisi tabel secara online melalui pernyataan SQL “ALTER TABLE MODIFY PARTITION”.
Fitur baru ini memungkinkan kami untuk mengadaptasi metode partisi untuk tabel tanpa memerlukan waktu henti terkait untuk membuat perubahan.
Kecuali Anda menentukan klausa “UPDATE INDEXES” sebagai bagian dari pernyataan “ALTER TABLE”:
– Basis data menandai UNUSABLE semua hasil partisi atau subpartisi indeks lokal terkait yang dihasilkan.
– Indeks global, atau semua partisi indeks global yang dipartisi, ditandai UNUSABLE dan harus dibangun kembali.
Contoh ini memberikan demonstrasi langkah demi langkah tugas yang diperlukan untuk mengonversi tabel partisi RANGE menjadi tabel partisi HASH.
Tampilkan partisi tabel ATP01_CRED_PAG:
# sqlplus / as sysdba SQL*Plus: Release 18.0.0.0.0 - Production on Wed Jun 17 16:39:51 2020 Version 18.2.0.0.0 Copyright (c) 1982, 2018, Oracle. All rights reserved. Connected to: Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production Version 18.2.0.0.0 SQL> select table_name, partition_name, partition_position from dba_tab_partitions where table_name='ATP01_CRED_PAG'; TABLE_NAME PARTITION_NAME PARTITION_POSITION ----------------------------------------------------- ATP01_CRED_PAG PART_199501 1 ATP01_CRED_PAG PART_199412 2 ATP01_CRED_PAG PART_199506 3 SQL> select count(1) from ATP01_CRED_PAG partition (PART_199501); COUNT(1) ---------- 3908 SQL> select count(1) from ATP01_CRED_PAG partition (PART_199412); COUNT(1) ---------- 3984 SQL> select count(1) from ATP01_CRED_PAG partition (PART_199506); COUNT(1) ---------- 1363
Tampilkan metode partisi (RANGE) dari tabel ATP01_CRED_PAG:
SQL> select owner, table_name, partitioning_type, autolist, interval, autolist_subpartition from dba_part_tables where table_name = 'ATP01_CRED_PAG'; OWNER TABLE_NAME PARTITION AUT INTERVAL AUT -------- -------------- -------- ---- --------- ------ ADMIN ATP01_CRED_PAG RANGE NO NO
Konversi RANGE tabel yang dipartisi ke tabel yang dipartisi HASH ONLINE:
SQL> ALTER TABLE ATP01_CRED_PAG MODIFY PARTITION BY HASH (DT_COMPETENCIA) PARTITIONS 3 ONLINE; Table altered.
Menampilkan metode partisi baru (HASH):
SQL> select owner, table_name, partitioning_type, autolist, interval, autolist_subpartition from dba_part_tables where table_name = 'ATP01_CRED_PAG'; OWNER TABLE_NAME PARTITION AUT INTERVAL AUT -------- ------------- --------- --- -------- ----- ADMIN ATP01_CRED_PAG HASH NO NO
Menampilkan partisi tabel:
SQL> select table_name, partition_name, partition_position from dba_tab_partitions where table_name='ATP01_CRED_PAG'; TABLE_NAME PARTITION_NAME PARTITION_POSITION ----------------- ---------------- ------------------ ATP01_CRED_PAG SYS_P621 1 ATP01_CRED_PAG SYS_P622 2 ATP01_CRED_PAG SYS_P623 3 SQL> select count(1) from ATP01_CRED_PAG partition (SYS_P621); COUNT(1) ---------- 2651 SQL> select count(1) from ATP01_CRED_PAG partition (SYS_P622); COUNT(1) ---------- 6604 SQL> select count(1) from ATP01_CRED_PAG partition (SYS_P623); COUNT(1) ---------- 0
Referensi
Operasi Pemeliharaan untuk Tabel dan Indeks yang Dipartisi. Tersedia di https://docs.Oracle.com/en/database/Oracle/Oracle-database/18/vldbg/maintenance-partition-tables-indexes.html#GUID-0E7793F7-B38A-427E-846B-7A8651F2A523