sql >> Database teknologi >  >> RDS >> Oracle

Oracle 18c Ny funktion:Online ændring af partitionering

I Oracle Database 18c ændrer vi nu partitioneringsstrategien online for en tabel via SQL-sætningen "ALTER TABLE MODIFY PARTITION".

Denne nye funktion gør det muligt for os at tilpasse partitioneringsmetoden til en tabel uden at kræve nogen tilhørende nedetid for at foretage ændringen.

Medmindre du angiver "UPDATE INDEXES"-klausulen som en del af "ALTER TABLE"-sætningen:

– Databasen markerer UNUSBLE alle resulterende tilsvarende lokale indekspartitioner eller underpartitioner.
– Globale indekser, eller alle partitioner af partitionerede globale indekser, er markeret UNUSBLE og skal genopbygges.

Dette eksempel giver en trinvis demonstration af de opgaver, der kræves for at konvertere RANGE-partitionstabel til en HASH-partitionstabel.

Vis partitionerne i tabellen 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

Vis partitioneringsmetoden (RANGE) i tabellen 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

Konverter RANGE-partitioneret tabel til HASH-partitioneret tabel ONLINE:


SQL> ALTER TABLE ATP01_CRED_PAG MODIFY PARTITION BY HASH (DT_COMPETENCIA) PARTITIONS 3 ONLINE;

Table altered.

Viser den nye partitioneringsmetode (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

Vis tabellens partitioner:


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

Referencer

Vedligeholdelseshandlinger for opdelte tabeller og indekser. Tilgængelig på https://docs.oracle.com/en/database/oracle/oracle-database/18/vldbg/maintenance-partition-tables-indexes.html#GUID-0E7793F7-B38A-427E-846B-7A8651F2A523


  1. Sådan installeres PgBackRest

  2. Sådan opretter du MySQL-visning

  3. Hvornår skal jeg bruge et semikolon vs en skråstreg i Oracle SQL?

  4. Hurtigste måde at afgøre, om posten eksisterer