SlideShare a Scribd company logo
1 of 4
Anar Godjaevhttp://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;
Anar Godjaevhttp://anargodjaev.wordpress.com/
Dropping index partitions:
ALTER INDEX npr DROP PARTITION P1;
ALTER INDEX npr REBUILD PARTITION P2;

Hash Partition:
The following example creates a hash‐partitioned table. The partitioning column is id, four
partitions are created and assigned system generated names, and they are placed in four
named tablespaces (gear1, gear2, ...).
CREATE TABLE scubagear
(id NUMBER,
name VARCHAR2 (60))
PARTITION BY HASH (id)
PARTITIONS 4
STORE IN (gear1, gear2, gear3, gear4);
ALTER TABLE scubagear ADD PARTITION p_named TABLESPACE gear5;

List Partition:
The following example creates a list‐partitioned table. It creates table q1_sales_by_region
which is partitioned by regions consisting of groups of states.
CREATE TABLE q1_sales_by_region
(deptno number,
deptname varchar2(20),
quarterly_sales number(10, 2),
state varchar2(2))
PARTITION BY LIST (state)
(PARTITION q1_northwest VALUES ('OR', 'WA'),
PARTITION q1_southwest VALUES ('AZ', 'UT', 'NM'),
PARTITION q1_northeast VALUES ('NY', 'VM', 'NJ'),
PARTITION q1_southeast VALUES ('FL', 'GA'),
PARTITION q1_northcentral VALUES ('SD', 'WI'),
PARTITION q1_southcentral VALUES ('OK', 'TX'));
ALTER TABLE q1_sales_by_region
ADD PARTITION q1_nonmainland VALUES ('HI', 'PR')
STORAGE (INITIAL 20K NEXT 20K) TABLESPACE tbs_3
NOLOGGING;
ALTER TABLE q1_sales_by_region
MERGE PARTITIONS q1_northcentral, q1_southcentral
INTO PARTITION q1_central
PCTFREE 50 STORAGE(MAXEXTENTS 20);

Range‐Hash Partition:
The following statement creates a range‐hash partitioned table. In this example, three range
partitions are created, each containing eight subpartitions. Because the subpartitions are not
named, system generated names are assigned, but the STORE IN clause distributes them
Anar Godjaevhttp://anargodjaev.wordpress.com/
across the 4 specified tablespaces (ts1, ...,ts4).
CREATE TABLE scubagear (equipno NUMBER, equipname VARCHAR(32), price
NUMBER)
PARTITION BY RANGE (equipno) SUBPARTITION BY HASH(equipname)
SUBPARTITIONS 8 STORE IN (ts1, ts2, ts3, ts4)
(PARTITION p1 VALUES LESS THAN (1000),
PARTITION p2 VALUES LESS THAN (2000),
PARTITION p3 VALUES LESS THAN (MAXVALUE));

Range‐List Partition:
The following example illustrates how range‐list partitioning might be used. The example
tracks sales data of products by quarters and within each quarter, groups it by specified
states.
CREATE TABLE quarterly_regional_sales
(deptno number, item_no varchar2(20),
txn_date date, txn_amount number, 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','DD-MONYYYY'))
(SUBPARTITION q1_2013_northwest VALUES ('OR', 'WA'),
SUBPARTITION q1_2013_southwest VALUES ('AZ', 'UT', 'NM'),
SUBPARTITION q1_2013_northeast VALUES ('NY', 'VM', 'NJ'),
SUBPARTITION q1_2013_southeast VALUES ('FL', 'GA'),
SUBPARTITION q1_2013_northcentral VALUES ('SD', 'WI'),
SUBPARTITION q1_2013_southcentral VALUES ('OK', 'TX')
),
PARTITION q2_2013 VALUES LESS THAN ( TO_DATE('1-JUL-2013','DD-MONYYYY'))
(SUBPARTITION q2_2013_northwest VALUES ('OR', 'WA'),
SUBPARTITION q2_2013_southwest VALUES ('AZ', 'UT', 'NM'),
SUBPARTITION q2_2013_northeast VALUES ('NY', 'VM', 'NJ'),
SUBPARTITION q2_2013_southeast VALUES ('FL', 'GA'),
SUBPARTITION q2_2013_northcentral VALUES ('SD', 'WI'),
SUBPARTITION q2_2013_southcentral VALUES ('OK', 'TX')
),
PARTITION q3_2013 VALUES LESS THAN (TO_DATE('1-OCT-2013','DD-MONYYYY'))
(SUBPARTITION q3_2013_northwest VALUES ('OR', 'WA'),
SUBPARTITION q3_2013_southwest VALUES ('AZ', 'UT', 'NM'),
SUBPARTITION q3_2013_northeast VALUES ('NY', 'VM', 'NJ'),
SUBPARTITION q3_2013_southeast VALUES ('FL', 'GA'),
SUBPARTITION q3_2013_northcentral VALUES ('SD', 'WI'),
SUBPARTITION q3_2013_southcentral VALUES ('OK', 'TX')
));
ALTER TABLE quarterly_regional_sales
MODIFY SUBPARTITION q1_2013_southeast
ADD VALUES ('KS');
Anar Godjaevhttp://anargodjaev.wordpress.com/
ALTER TABLE quarterly_regional_sales
MODIFY SUBPARTITION q1_2013_southeast
DROP VALUES ('KS');

More Related Content

Viewers also liked (12)

How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...
 
Oracle Golden Gate
Oracle Golden GateOracle Golden Gate
Oracle Golden Gate
 
Tuning SGA
Tuning SGATuning SGA
Tuning SGA
 
Oracle GoldenGate
Oracle GoldenGateOracle GoldenGate
Oracle GoldenGate
 
Asm disk group migration from
Asm disk group migration from Asm disk group migration from
Asm disk group migration from
 
Wait Interface
Wait InterfaceWait Interface
Wait Interface
 
Conditional Control
Conditional ControlConditional Control
Conditional Control
 
Backup and Recovery
Backup and RecoveryBackup and Recovery
Backup and Recovery
 
Database Vault / Verinin Güvenliği
Database Vault /  Verinin GüvenliğiDatabase Vault /  Verinin Güvenliği
Database Vault / Verinin Güvenliği
 
Audit Mekani̇zmasi
Audit Mekani̇zmasiAudit Mekani̇zmasi
Audit Mekani̇zmasi
 
Backup and Recovery Procedure
Backup and Recovery ProcedureBackup and Recovery Procedure
Backup and Recovery Procedure
 
how to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaulthow to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vault
 

Similar to Table Partitions

Appendix A Tables
Appendix A   TablesAppendix A   Tables
Appendix A Tables
LiquidHub
 
0104 abap dictionary
0104 abap dictionary0104 abap dictionary
0104 abap dictionary
vkyecc1
 
Appendix A Tables
Appendix A   TablesAppendix A   Tables
Appendix A Tables
LiquidHub
 
Final ProjectBe sure to follow the instructions for each step as.docx
Final ProjectBe sure to follow the instructions for each step as.docxFinal ProjectBe sure to follow the instructions for each step as.docx
Final ProjectBe sure to follow the instructions for each step as.docx
voversbyobersby
 
Using ddl statements to create and manage tables
Using ddl statements to create and manage tablesUsing ddl statements to create and manage tables
Using ddl statements to create and manage tables
Syed Zaid Irshad
 

Similar to Table Partitions (20)

Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
 
Les09
Les09Les09
Les09
 
Ppt INFORMATIVE PRACTICES for class 11th chapter 14
Ppt INFORMATIVE PRACTICES for class 11th chapter 14Ppt INFORMATIVE PRACTICES for class 11th chapter 14
Ppt INFORMATIVE PRACTICES for class 11th chapter 14
 
Oracle eCommerce (ATG) Database Best Practices
Oracle eCommerce (ATG) Database  Best Practices Oracle eCommerce (ATG) Database  Best Practices
Oracle eCommerce (ATG) Database Best Practices
 
Sap abap
Sap abapSap abap
Sap abap
 
Appendix A Tables
Appendix A   TablesAppendix A   Tables
Appendix A Tables
 
write a List class to store your Vehicle objects. you've decided that your im...
write a List class to store your Vehicle objects. you've decided that your im...write a List class to store your Vehicle objects. you've decided that your im...
write a List class to store your Vehicle objects. you've decided that your im...
 
Devry bis 155 week 3 quiz data analysis
Devry bis 155 week 3 quiz data analysisDevry bis 155 week 3 quiz data analysis
Devry bis 155 week 3 quiz data analysis
 
unit 1 ppt.pptx
unit 1 ppt.pptxunit 1 ppt.pptx
unit 1 ppt.pptx
 
Les10 Creating And Managing Tables
Les10 Creating And Managing TablesLes10 Creating And Managing Tables
Les10 Creating And Managing Tables
 
0104 abap dictionary
0104 abap dictionary0104 abap dictionary
0104 abap dictionary
 
Les09
Les09Les09
Les09
 
Write a List class to store Vehicle objects. The implementation of List will ...
Write a List class to store Vehicle objects. The implementation of List will ...Write a List class to store Vehicle objects. The implementation of List will ...
Write a List class to store Vehicle objects. The implementation of List will ...
 
Write a List class to store Vehicle objects. The implementation of List will ...
Write a List class to store Vehicle objects. The implementation of List will ...Write a List class to store Vehicle objects. The implementation of List will ...
Write a List class to store Vehicle objects. The implementation of List will ...
 
Appendix A Tables
Appendix A   TablesAppendix A   Tables
Appendix A Tables
 
Final ProjectBe sure to follow the instructions for each step as.docx
Final ProjectBe sure to follow the instructions for each step as.docxFinal ProjectBe sure to follow the instructions for each step as.docx
Final ProjectBe sure to follow the instructions for each step as.docx
 
Les10
Les10Les10
Les10
 
Procedure To Store Database Object Size And Number Of Rows In Custom Table
Procedure To Store Database Object Size And Number Of Rows In Custom TableProcedure To Store Database Object Size And Number Of Rows In Custom Table
Procedure To Store Database Object Size And Number Of Rows In Custom Table
 
Using ddl statements to create and manage tables
Using ddl statements to create and manage tablesUsing ddl statements to create and manage tables
Using ddl statements to create and manage tables
 
w_dzon05
w_dzon05w_dzon05
w_dzon05
 

More from Anar Godjaev

Oracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumOracle 10g Database Server Kurulum
Oracle 10g Database Server Kurulum
Anar Godjaev
 
DataPump ile Single Parititon Export
DataPump ile Single Parititon ExportDataPump ile Single Parititon Export
DataPump ile Single Parititon Export
Anar Godjaev
 
Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇
Anar Godjaev
 
Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇
Anar Godjaev
 
Instance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeInstance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını Inceleme
Anar Godjaev
 
Oracle Managed Files
Oracle Managed FilesOracle Managed Files
Oracle Managed Files
Anar Godjaev
 
Recovery Manager (RMAN)
Recovery Manager (RMAN)Recovery Manager (RMAN)
Recovery Manager (RMAN)
Anar Godjaev
 
Oracle Enterprise Linux 5
Oracle Enterprise Linux 5Oracle Enterprise Linux 5
Oracle Enterprise Linux 5
Anar Godjaev
 
Oracle Database 11g R2 Installation
Oracle Database 11g R2 InstallationOracle Database 11g R2 Installation
Oracle Database 11g R2 Installation
Anar Godjaev
 
Oracle Tablespace Yonetimi
Oracle Tablespace YonetimiOracle Tablespace Yonetimi
Oracle Tablespace Yonetimi
Anar Godjaev
 

More from Anar Godjaev (19)

Oracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumOracle 10g Database Server Kurulum
Oracle 10g Database Server Kurulum
 
DataPump ile Single Parititon Export
DataPump ile Single Parititon ExportDataPump ile Single Parititon Export
DataPump ile Single Parititon Export
 
Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇
 
Contraints
ContraintsContraints
Contraints
 
Oracle SQL
Oracle SQLOracle SQL
Oracle SQL
 
Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇
 
Instance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeInstance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını Inceleme
 
PL/SQL Blocks
PL/SQL BlocksPL/SQL Blocks
PL/SQL Blocks
 
Parallel Server
Parallel ServerParallel Server
Parallel Server
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
LogMiner
LogMinerLogMiner
LogMiner
 
Undo Management
Undo ManagementUndo Management
Undo Management
 
ASM
ASMASM
ASM
 
Oracle Managed Files
Oracle Managed FilesOracle Managed Files
Oracle Managed Files
 
Recovery Manager (RMAN)
Recovery Manager (RMAN)Recovery Manager (RMAN)
Recovery Manager (RMAN)
 
Oracle Enterprise Linux 5
Oracle Enterprise Linux 5Oracle Enterprise Linux 5
Oracle Enterprise Linux 5
 
Oracle Database 11g R2 Installation
Oracle Database 11g R2 InstallationOracle Database 11g R2 Installation
Oracle Database 11g R2 Installation
 
Change DB Name
Change DB NameChange DB Name
Change DB Name
 
Oracle Tablespace Yonetimi
Oracle Tablespace YonetimiOracle Tablespace Yonetimi
Oracle Tablespace Yonetimi
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Table Partitions

  • 1. Anar Godjaevhttp://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;
  • 2. Anar Godjaevhttp://anargodjaev.wordpress.com/ Dropping index partitions: ALTER INDEX npr DROP PARTITION P1; ALTER INDEX npr REBUILD PARTITION P2; Hash Partition: The following example creates a hash‐partitioned table. The partitioning column is id, four partitions are created and assigned system generated names, and they are placed in four named tablespaces (gear1, gear2, ...). CREATE TABLE scubagear (id NUMBER, name VARCHAR2 (60)) PARTITION BY HASH (id) PARTITIONS 4 STORE IN (gear1, gear2, gear3, gear4); ALTER TABLE scubagear ADD PARTITION p_named TABLESPACE gear5; List Partition: The following example creates a list‐partitioned table. It creates table q1_sales_by_region which is partitioned by regions consisting of groups of states. CREATE TABLE q1_sales_by_region (deptno number, deptname varchar2(20), quarterly_sales number(10, 2), state varchar2(2)) PARTITION BY LIST (state) (PARTITION q1_northwest VALUES ('OR', 'WA'), PARTITION q1_southwest VALUES ('AZ', 'UT', 'NM'), PARTITION q1_northeast VALUES ('NY', 'VM', 'NJ'), PARTITION q1_southeast VALUES ('FL', 'GA'), PARTITION q1_northcentral VALUES ('SD', 'WI'), PARTITION q1_southcentral VALUES ('OK', 'TX')); ALTER TABLE q1_sales_by_region ADD PARTITION q1_nonmainland VALUES ('HI', 'PR') STORAGE (INITIAL 20K NEXT 20K) TABLESPACE tbs_3 NOLOGGING; ALTER TABLE q1_sales_by_region MERGE PARTITIONS q1_northcentral, q1_southcentral INTO PARTITION q1_central PCTFREE 50 STORAGE(MAXEXTENTS 20); Range‐Hash Partition: The following statement creates a range‐hash partitioned table. In this example, three range partitions are created, each containing eight subpartitions. Because the subpartitions are not named, system generated names are assigned, but the STORE IN clause distributes them
  • 3. Anar Godjaevhttp://anargodjaev.wordpress.com/ across the 4 specified tablespaces (ts1, ...,ts4). CREATE TABLE scubagear (equipno NUMBER, equipname VARCHAR(32), price NUMBER) PARTITION BY RANGE (equipno) SUBPARTITION BY HASH(equipname) SUBPARTITIONS 8 STORE IN (ts1, ts2, ts3, ts4) (PARTITION p1 VALUES LESS THAN (1000), PARTITION p2 VALUES LESS THAN (2000), PARTITION p3 VALUES LESS THAN (MAXVALUE)); Range‐List Partition: The following example illustrates how range‐list partitioning might be used. The example tracks sales data of products by quarters and within each quarter, groups it by specified states. CREATE TABLE quarterly_regional_sales (deptno number, item_no varchar2(20), txn_date date, txn_amount number, 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','DD-MONYYYY')) (SUBPARTITION q1_2013_northwest VALUES ('OR', 'WA'), SUBPARTITION q1_2013_southwest VALUES ('AZ', 'UT', 'NM'), SUBPARTITION q1_2013_northeast VALUES ('NY', 'VM', 'NJ'), SUBPARTITION q1_2013_southeast VALUES ('FL', 'GA'), SUBPARTITION q1_2013_northcentral VALUES ('SD', 'WI'), SUBPARTITION q1_2013_southcentral VALUES ('OK', 'TX') ), PARTITION q2_2013 VALUES LESS THAN ( TO_DATE('1-JUL-2013','DD-MONYYYY')) (SUBPARTITION q2_2013_northwest VALUES ('OR', 'WA'), SUBPARTITION q2_2013_southwest VALUES ('AZ', 'UT', 'NM'), SUBPARTITION q2_2013_northeast VALUES ('NY', 'VM', 'NJ'), SUBPARTITION q2_2013_southeast VALUES ('FL', 'GA'), SUBPARTITION q2_2013_northcentral VALUES ('SD', 'WI'), SUBPARTITION q2_2013_southcentral VALUES ('OK', 'TX') ), PARTITION q3_2013 VALUES LESS THAN (TO_DATE('1-OCT-2013','DD-MONYYYY')) (SUBPARTITION q3_2013_northwest VALUES ('OR', 'WA'), SUBPARTITION q3_2013_southwest VALUES ('AZ', 'UT', 'NM'), SUBPARTITION q3_2013_northeast VALUES ('NY', 'VM', 'NJ'), SUBPARTITION q3_2013_southeast VALUES ('FL', 'GA'), SUBPARTITION q3_2013_northcentral VALUES ('SD', 'WI'), SUBPARTITION q3_2013_southcentral VALUES ('OK', 'TX') )); ALTER TABLE quarterly_regional_sales MODIFY SUBPARTITION q1_2013_southeast ADD VALUES ('KS');
  • 4. Anar Godjaevhttp://anargodjaev.wordpress.com/ ALTER TABLE quarterly_regional_sales MODIFY SUBPARTITION q1_2013_southeast DROP VALUES ('KS');