OCM Tips and Tricks - Partition

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

6/17/2021 OCM Tips and Tricks – OCM Guide

To get more detailed information and SQL syntax related with composite partitioning tables, refer to the
documentation that is provided in the beginning of the chapter and go to “Creating Composite
Partitioned Tables” section. Check the following documentation to get more detailed information about
the composite partitioning:

Oracle® Database VLDB and Partitioning Guide -> Creating Partitions

Sometimes, defining only one partition is not enough. By creating a composite partition, the table is
firstly partitioned by the first data distribution method, and then each partition is subpartitioned by the
second data distribution method.

In this and next post, we will talk about the following composite partitioned tables:

Range-hash partitioning
Range-list partitioning
Range-range partitioning
List-range partitioning
List-hash partitioning
List-list partitioning
Hash-hash partitioning
Interval-list partitioning
Interval-range partitioning
Interval-hash partitioning

Note: Only Range-Hash and Range-List composite partitions can be created from OEM.

Range-Hash partitioning

To create a range-hash partitioned table, use PARTITION BY RANGE SUBPARTITION BY HASH


syntax as follows:

SQL> CREATE TABLE tbl_range_hash_part

PARTITION BY RANGE

(object_id)

SUBPARTITION BY HASH (namespace)

SUBPARTITIONS 4

PARTITION part1 VALUES LESS THAN (1000),

PARTITION part2 VALUES LESS THAN (10000),

PARTITION part3 VALUES LESS THAN (30000),

PARTITION part4 VALUES LESS THAN (maxvalue))

AS

SELECT * FROM dba_objects;

Table created.

SQL>

www.ocmguide.com/category/ocm-tips-and-tricks/ 1/2
6/17/2021 OCM Tips and Tricks – OCM Guide

Gather the statistics of the table to update the statistics at DBA_TAB_PARTITIONS:

SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS(‘sys’,’tbl_range_hash_part’);

PL/SQL procedure successfully completed.

To get the list of range partitions and the data distribution, query DBA_TAB_PARTITIONS view as
follows:

SQL> SELECT table_name,

partition_name,

subpartition_count,

num_rows,

blocks

FROM dba_tab_partitions

WHERE table_name = ‘TBL_RANGE_HASH_PART’;

TABLE_NAME PARTITION_NAME SUBPARTITION_COUNT NUM_ROWS BLOCKS

------------------------- ---------------------- ---------------- ---------- ---------

TBL_RANGE_HASH_PART PART1 4 942 12

TBL_RANGE_HASH_PART PART2 4 8763 113

TBL_RANGE_HASH_PART PART3 4 19802 287

TBL_RANGE_HASH_PART PART4 4 45740 666

www.ocmguide.com/category/ocm-tips-and-tricks/ 2/2

You might also like