设为首页 收藏本站
查看: 1081|回复: 0

[经验分享] Rotate partitions in DB2 on z

[复制链接]

尚未签到

发表于 2016-11-19 01:19:14 | 显示全部楼层 |阅读模式
Rotating partitions







DSC0000.gif 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. DSC0001.gif



About this task


Recommendation: DSC0002.gif 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. DSC0003.gif   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:


  • Issue the ALTER TABLE statement and specify the ROTATE PARTITION option.
  • 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

PartitionLimit valueData 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

PartitionLimit valueData 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






  • Parent topic: Altering partitions


Related tasks:

  • Changing the boundary between partitions
  • Extending the boundary of the last partition
  • Splitting the last partition into two
  • Inserting rows at the end of a partition

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-302163-1-1.html 上篇帖子: [DB2]DB2日常维护——REORG TABLE命令优化数据库性能 下篇帖子: DB2数据库常用基本操作命令
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表