Rotating partitions

 

You can use the ALTER TABLE statement to rotate any logical partition to become the last partition. Rotating partitions is supported for partitioned (non-universal) table spaces and range-partitioned table spaces, but not for partition-by-growth table spaces.

About this task

Recommendation: When you create a partitioned table space, you do not need to allocate extra partitions for expected growth. Instead, you can use the ALTER TABLE ADD PARTITION statement to add partitions as needed. If rotating partitions is appropriate for your application, use the ALTER TABLE ROTATE PARTITION statement to avoid adding another partition.

Nullable partitioning columns: DB2® lets you use nullable columns as partitioning columns. But with table-controlled partitioning, DB2 can restrict the insertion of null values into a table with nullable partitioning columns, depending on the order of the partitioning key. After a rotate operation, if the partitioning key is ascending, DB2 prevents an INSERT of a row with a null value for the key column. If the partitioning key is descending, DB2 allows an INSERT of a row with a null value for the key column. The row is inserted into the first partition.

Procedure

To rotate a partition to be the last partition:

  1. Issue the ALTER TABLE statement and specify the ROTATE PARTITION option.
  2. Optional: Run the RUNSTATS utility.

Example

For example, assume that the partition structure of the table space is sufficient through the year 2006. The following table shows a representation of the table space through the year 2006. When another partition is needed for the year 2007, you determined that the data for 1996 is no longer needed. You want to recycle the partition for the year 1996 to hold the transactions for the year 2007.

Table 1. An excerpt of a partitioned table space
Partition Limit value Data set name that backs the partition
P008 12/31/2004 catname.DSNDBx.dbname.psname.I0001.A008
P009 12/31/2005 catname.DSNDBx.dbname.psname.I0001.A009
P010 12/31/2006 catname.DSNDBx.dbname.psname.I0001.A010

To rotate the first partition for table TRANS to be the last partition, issue the following statement:

ALTER TABLE TRANS ROTATE PARTITION FIRST TO LAST
ENDING AT ('12/31/2007') RESET;

For a table with limit values in ascending order, the data in the ENDING AT clause must be higher than the limit value for previous partitions. DB2 chooses the first partition to be the partition with the lowest limit value.

For a table with limit values in descending order, the data must be lower than the limit value for previous partitions. DB2 chooses the first partition to be the partition with the highest limit value.

The RESET keyword specifies that the existing data in the first logical partition is deleted, and no delete triggers are activated. Because the oldest (or first) partition is P001, DB2 assigns the new limit value to P001. This partition holds all rows in the range between the new limit value of 12/31/2007 and the previous limit value of 12/31/2006. The RESET operation deletes all existing data. You can use the partition immediately after the ALTER completes. The partition is not placed in REORG-pending (REORP) status, if the table is large, or if the last partition before the rotation is empty.

The following table shows a representation of the table space after the first partition is rotated to become the last partition.

Table 2. Rotating the first partition to be the last partition
Partition Limit value Data set name that backs the partition
P002 12/31/1997 catname.DSNDBx.dbname.psname.I0001.A002
P003 12/31/1998 catname.DSNDBx.dbname.psname.I0001.A003
P004 12/31/1999 catname.DSNDBx.dbname.psname.I0001.A004
P005 12/31/2000 catname.DSNDBx.dbname.psname.I0001.A005
P006 12/31/2001 catname.DSNDBx.dbname.psname.I0001.A006
P007 12/31/2002 catname.DSNDBx.dbname.psname.I0001.A007
P008 12/31/2003 catname.DSNDBx.dbname.psname.I0001.A008
P009 12/31/2004 catname.DSNDBx.dbname.psname.I0001.A009
P010 12/31/2005 catname.DSNDBx.dbname.psname.I0001.A010
P011 12/31/2006 catname.DSNDBx.dbname.psname.I0001.A011
P001 12/31/2007 catname.DSNDBx.dbname.psname.I0001.A001

Rotate partitions in DB2 on z的更多相关文章

  1. DB2 for z: system catalog tables

    http://www.ibm.com/support/knowledgecenter/SSEPEK_10.0.0/com.ibm.db2z10.doc.sqlref/src/tpc/db2z_cata ...

  2. 在DB2 for z/os上创建指定pagesize的数据库

    ASNTDIFF的diff table有一列类型为varchar 15000,z上创建db默认的pagesize是4K,无法创建table,所以需要创建一个大pagesize的database. db ...

  3. Index on DB2 for z/OS: DB2 for z/OS 的索引

    可以创建在任何表上的索引: Unique Index:An index that ensures that the value in a particular column or set of col ...

  4. DB2 for Z/os Statement prepare

    The PREPARE statement creates an executable SQL statement from a string form of the statement. The c ...

  5. DB2 bind on z/os

    BIND and REBIND options for packages and plans There are several options you can use for binding or ...

  6. OGG for DB2 z/OS 12.2版本发布

    2016-04-15 Oracle发布了GoldenGate for DB2 z/OS  12.2.0.1.2.可以从OTN或eDelivery下载,该版本是ogg for DB2 z/OS的第一个1 ...

  7. 免费数据库(SQLite、Berkeley DB、PostgreSQL、MySQL、Firebird、mSQL、MSDE、DB2 Express-C、Oracle XE)

    SQLite数据库是中小站点CMS的最佳选择 SQLite 是一个类似Access的轻量级数据库系统,但是更小.更快.容量更大,并发更高.为什么说 SQLite 最适合做 CMS (内容管理系统)呢? ...

  8. DB2调优摘要

    感谢原博主 http://yishueitian326.blog.163.com/blog/static/2858637520106695733719/ 性 能是关系到随需应变型应用程序成功与否的关键 ...

  9. (转)调优 DB2 UDB v8.1 及其数据库的最佳实践

    原文:https://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0404mcarthur/index.html 简介 性能是 ...

随机推荐

  1. Effective Java 读书笔记之四 泛型

    泛型的本质是参数化类型.只对编译器有效. 一.请不要在新代码中使用原生态类型 1.泛型类和接口统称为泛型,有一个对应的原生态类型. 2.原生类型的存在是为了移植兼容性. 3.无限制通配类型和原生态类型 ...

  2. HDU 4923 Room and Moor

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4923 解题报告:给出一个长度为n的只包含0和1的序列,是否存在一个序列Bi满足一下条件: 1.     ...

  3. BZOJ4612——[Wf2016]Forever Young

    1.题意:将一个数y转化成b进制数,使得他>=l,且<y,且转化后均为0~9,使b最大. 2.分析:我们发现要么答案的b很小,要么y很小..那我们直接暴力枚举就好了啊 然后判断一下...另 ...

  4. Python之函数之路

    1 集合 集合是一个无序的,不重复的数据组合,它的主要作用如下: 去重,把一个列表变成集合,就自动去重了 关系测试,测试两组数据之前的交集.差集.并集等关系 创建集合 a = {3, 5, 9, 9, ...

  5. 4.5---判断是否是二叉排序树BST(CC150)

    public boolean checkBST(TreeNode root) { return isBST(root, Long.MIN_VALUE, Long.MAX_VALUE); } publi ...

  6. [转载]C++虚函数浅析

    原文:http://glgjing.github.io/blog/2015/01/03/c-plus-plus-xu-han-shu-qian-xi/ 感谢:单刀土豆 C++虚函数浅析 JAN 3RD ...

  7. POJ 1321

    http://poj.org/problem?id=1321 一道深搜的题目,和那个POJ3740有点相类似. 也是到了现在我才知道原来深搜也有几种套路的,以前我的都是用队列来做,那个是不需要记住什么 ...

  8. centos查找未挂载磁盘格式化并挂载

    查看当前linux服务器分区 df -h 查看当前linux服务器硬盘: fdisk -l /dev/sda   第一块硬盘 /dev/sdb   第二块硬盘 依此类推 以/dev/sdb为新增硬盘为 ...

  9. Delphi XE5 常见问题解答

    Delphi XE5 常见问题解答 有关于新即时试用的问题吗?请看看 RAD Studio 即时试用常见问答. 常见问题 什么是 Delphi? Embarcadero? Delphi? XE5 是易 ...

  10. java读取excel

    /* * this function will read from excel * and will return the items of excel */ public static String ...