Anar Godjaev

http://anargodjaev.wordpress.com/

Table Partitions:
Range partition: The example below creates a table of four partitions, one for each quarter's sales. The columns sale_year, sale_month, and sale_day are the partitioning columns, while their values constitute a specific row's partitioning key. The VALUES LESS THAN clause determines the partition bound: rows with partitioning key values that compare less than the ordered list of values specified by the clause are stored in the partition. Each partition is given a name (sales_q1, sales_q2, ...), and each partition is contained in a separate tablespace (tsa, tsb, ...).
CREATE TABLE sales ( invoice_no NUMBER, sale_year INT NOT NULL, sale_month INT NOT NULL, sale_day INT NOT NULL ) PARTITION BY RANGE (sale_year, sale_month, sale_day) ( PARTITION sales_q1 VALUES LESS THAN (2012, 04, 01) TABLESPACE tsa, PARTITION sales_q2 VALUES LESS THAN (2012 07, 01) TABLESPACE tsb, PARTITION sales_q3 VALUES LESS THAN (2012, 10, 01) TABLESPACE tsc, PARTITION sales_q4 VALUES LESS THAN (2013, 01, 01) TABLESPACE tsd ); ALTER TABLE sales ADD PARTITION jan96 VALUES LESS THAN ( '26-FEB-2013' ) TABLESPACE tsx; ALTER TABLE sales DROP PARTITION dec98; ALTER INDEX sales_area_ix REBUILD; (if global index exists) DELETE FROM sales WHERE TRANSID < 10000; ALTER TABLE sales DROP PARTITION dec98 ALTER TABLE sales DROP PARTITION dec98 UPDATE GLOBAL INDEXES; ALTER TABLE four_seasons MERGE PARTITIONS quarter_one, quarter_two INTO PARTITION quarter_two; CREATE INDEX i_four_seasons_l ON four_seasons ( one,two ) LOCAL ( PARTITION i_quarter_one TABLESPACE i_quarter_one, PARTITION i_quarter_two TABLESPACE i_quarter_two, PARTITION i_quarter_three TABLESPACE i_quarter_three, PARTITION i_quarter_four TABLESPACE i_quarter_four ); ALTER TABLE four_seasons MODIFY PARTITION quarter_two REBUILD UNUSABLE LOCAL INDEXES; ALTER TABLE four_seasons TRUNCATE PARTITION quartes_one;

'PR') STORAGE (INITIAL 20K NEXT 20K) TABLESPACE tbs_3 NOLOGGING. but the STORE IN clause distributes them . name VARCHAR2 (60)) PARTITION BY HASH (id) PARTITIONS 4 STORE IN (gear1. four partitions are created and assigned system generated names. CREATE TABLE q1_sales_by_region (deptno number. 2).).. Because the subpartitions are not named. http://anargodjaev. gear2. 'WI'). system generated names are assigned. three range partitions are created. each containing eight subpartitions. gear3. ALTER INDEX npr REBUILD PARTITION P2.wordpress. . gear4). deptname varchar2(20). ALTER TABLE q1_sales_by_region MERGE PARTITIONS q1_northcentral. It creates table q1_sales_by_region which is partitioned by regions consisting of groups of states. The partitioning column is id. PARTITION q1_southeast VALUES ('FL'. In this example. 'WA').Anar Godjaev Dropping index partitions: ALTER INDEX npr DROP PARTITION P1. PARTITION q1_northcentral VALUES ('SD'. ALTER TABLE q1_sales_by_region ADD PARTITION q1_nonmainland VALUES ('HI'. 'TX')). 'VM'.com/ Hash Partition: The following example creates a hash‐partitioned table. PARTITION q1_northeast VALUES ('NY'. 'NM'). 'NJ'). gear2. Range‐Hash Partition: The following statement creates a range‐hash partitioned table. 'GA'). PARTITION q1_southwest VALUES ('AZ'. CREATE TABLE scubagear (id NUMBER. ALTER TABLE scubagear ADD PARTITION p_named TABLESPACE gear5.. and they are placed in four named tablespaces (gear1. quarterly_sales number(10. 'UT'. PARTITION q1_southcentral VALUES ('OK'. List Partition: The following example creates a list‐partitioned table. q1_southcentral INTO PARTITION q1_central PCTFREE 50 STORAGE(MAXEXTENTS 20). state varchar2(2)) PARTITION BY LIST (state) (PARTITION q1_northwest VALUES ('OR'.

'NJ').'DD-MONYYYY')) (SUBPARTITION q2_2013_northwest VALUES ('OR'. equipname VARCHAR(32). 'WI'). 'NM'). SUBPARTITION q1_2013_southwest VALUES ('AZ'.. 'GA'). SUBPARTITION q1_2013_southeast VALUES ('FL'. 'WA'). . txn_amount number. 'NJ'). price NUMBER) PARTITION BY RANGE (equipno) SUBPARTITION BY HASH(equipname) SUBPARTITIONS 8 STORE IN (ts1. 'GA'). item_no varchar2(20). 'NM'). PARTITION q2_2013 VALUES LESS THAN ( TO_DATE('1-JUL-2013'. 'WI'). PARTITION p3 VALUES LESS THAN (MAXVALUE)). SUBPARTITION q2_2013_northeast VALUES ('NY'. SUBPARTITION q2_2013_northcentral VALUES ('SD'. 'WA'). 'WA').'DD-MONYYYY')) (SUBPARTITION q1_2013_northwest VALUES ('OR'.ts4). 'NM').Anar Godjaev across the 4 specified tablespaces (ts1. PARTITION q3_2013 VALUES LESS THAN (TO_DATE('1-OCT-2013'. state varchar2(2)) TABLESPACE ts4 PARTITION BY RANGE (txn_date) SUBPARTITION BY LIST (state) (PARTITION q1_2013 VALUES LESS THAN (TO_DATE('1-APR-2013'. SUBPARTITION q1_2013_northeast VALUES ('NY'. 'WI'). ts4) (PARTITION p1 VALUES LESS THAN (1000). CREATE TABLE quarterly_regional_sales (deptno number. 'VM'. 'UT'. 'VM'. The example tracks sales data of products by quarters and within each quarter. ts3. SUBPARTITION q3_2013_southeast VALUES ('FL'. SUBPARTITION q3_2013_northcentral VALUES ('SD'. 'TX') ).'DD-MONYYYY')) (SUBPARTITION q3_2013_northwest VALUES ('OR'. 'NJ'). 'GA'). SUBPARTITION q3_2013_northeast VALUES ('NY'. SUBPARTITION q1_2013_southcentral VALUES ('OK'. ts2. ALTER TABLE quarterly_regional_sales MODIFY SUBPARTITION q1_2013_southeast ADD VALUES ('KS'). 'TX') )). . groups it by specified states... 'UT'. SUBPARTITION q3_2013_southwest VALUES ('AZ'. http://anargodjaev. SUBPARTITION q2_2013_southwest VALUES ('AZ'. SUBPARTITION q1_2013_northcentral VALUES ('SD'. SUBPARTITION q2_2013_southcentral VALUES ('OK'.wordpress. SUBPARTITION q3_2013_southcentral VALUES ('OK'. PARTITION p2 VALUES LESS THAN (2000). 'VM'. Range‐List Partition: The following example illustrates how range‐list partitioning might be used. SUBPARTITION q2_2013_southeast VALUES ('FL'. 'TX') ). txn_date date.com/ CREATE TABLE scubagear (equipno NUMBER. 'UT'.

Anar Godjaev ALTER TABLE quarterly_regional_sales MODIFY SUBPARTITION q1_2013_southeast DROP VALUES ('KS').wordpress.com/ . http://anargodjaev.