HASH-PARTITIONED TABLES

La clausola PARTITION BY HASH dell’istruzione CREATE TABLE identifica che la tabella deve essere hash- partizionato. La clausola PARTITIONS può quindi essere utilizzata per specificare il numero di partizioni da creare e facoltativamente, i tablespace in cui memorizzarli. In alternativa, è possibile utilizzare clausole PARTITION per denominare il file singole partizioni e relativi tablespace.The only attribute you can specify for hash partitions is TABLESPACE.

Tutte le partizioni hash di una tabella deve condividere gli stessi attributi di segmento (eccetto TABLESPACE), che vengono ereditati dal livello di tabella.

Utilizzo del partizionamento di riferimento:

Il partizionamento hash è utile quando non c’è una chiave di intervallo evidente o il partizionamento dell’intervallo causerà irregolarità distribuzione dei dati. Il numero di partizioni deve essere una potenza di 2 (2, 4, 8, 16 …) e può essere specificato da PARTITIONS…STORE IN clause.
Esempio:
CREATE TABLE clothes
(clo_number NUMBER NOT NULL,
clo_date DATE NOT NULL,
clo_note VARCHAR2(100)
)
TABLESPACE users COMPRESS NOLOGGING
PARTITION BY HASH (clo_date)
PARTITIONS 2
STORE IN (users, users );
Or specified individually:
CREATE TABLE clothes
(clo_number NUMBER NOT NULL,
clo_date DATE NOT NULL,
clo_note VARCHAR2(100)
)
TABLESPACE users COMPRESS NOLOGGING
PARTITION BY HASH (clo_date)
(PARTITION p_winter VALUES LESS THAN (TO_DATE(’21/03/2016′, ‘DD/MM/YYYY’)) TABLESPACE users,
PARTITION p_spring VALUES LESS THAN (TO_DATE(’21/06/2016′, ‘DD/MM/YYYY’)) TABLESPACE users,
PARTITION p_summer VALUES LESS THAN (TO_DATE(’21/09/2016′, ‘DD/MM/YYYY’)) TABLESPACE users,
PARTITION p_fall VALUES LESS THAN (TO_DATE(’21/12/2016′, ‘DD/MM/YYYY’)) TABLESPACE users,
PARTITION p_others VALUES LESS THAN (MAXVALUE) TABLESPACE users
);
Scarica lo script che contiene entrambi gli scenari visti:

HASH-PARTITIONED TABLES – script.sql
Around the scenery:
– Link to others type of partitions already discussed:
– RANGE-PARTITIONED TABLES (articolo di Novembre)
– LIST-PARTITIONED TABLES and REFERENCE-PARTITIONED TABLES (articolo di Ottobre)
– INTERVALPARTITIONING (articolo di Settembre)
– Concept of Partitioning Partitioning enables tables and indexes to be subdivided into individual
smaller pieces. Each piece of the database object is called a partition. A partition has its own name,
and may optionally have its own storage characteristics. From the perspective of a database
administrator, a partitioned object has multiple pieces that can be managed either collectively or
individually.
Out of scope:
– Composite Partitioned Tables
– Hash-partitioned tables with global indexes

Potrebbero interessarti anche...

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *