Personal tools
You are here: Home DB2 DB2 UDB v9 How to add a new partition in a partitioned table
Navigation
Log in


Forgot your password?
 
Document Actions

How to add a new partition in a partitioned table

Add a new partition with the possibility to change the starting and ending boundary.

To create a partitioned table from the command line, issue the CREATE TABLE statement:

 

CREATE TABLE <NAME> (<column_name>  <data_type>  <null_attribute>) IN
   <table space list> PARTITION BY RANGE (<column expression>) 
    STARTING FROM <constant> ENDING <constant> EVERY <constant>

 

For example,

CREATE TABLE dbayear ( year INT) PARTITION BY RANGE (year) \
(STARTING FROM 1 ENDING AT 10, STARTING FROM 20 ENDING AT 30)

 

Checking the table partitions:

 

SELECT TABSCHEMA, TABNAME, DATAPARTITIONNAME, SEQNO, LOWVALUE, HIGHVALUE \
FROM SYSCAT.DATAPARTITIONS WHERE TABNAE='DBAYEAR' order by seqno"

 

Output:

 

TABSCHEMA TABNAME DATAPARTITIONNAME SEQNO LOWVALUE HIGHVALUE

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

DB2INST1 DBAYEAR PART0 0 1 10

DB2INST1 DBAYEAR PART1 1 20 30

 

 

Adding a new partition starting with 15:

ALTER TABLE DBAYEAR ADD PARTITION STARTING 15;

 

WARNING:

In this case the partitions were defined manually.

If you create a table using a role like "every 1 month" you will not be able to break the rule. For example:

 

CREATE TABLE dbayear ( year INT) PARTITION BY RANGE (year) \
(STARTING FROM 1 ENDING AT 100 EVERY 10)

 

Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls