Multiple columns can be specified in the PARTITION BY clause. This is similar to defining multiple columns in an index key:
CREATE TABLE SALES (YEAR INT, MONTH INT) PARTITION BY RANGE(YEAR, MONTH) ( STARTING (2007,1) ENDING (2007,3), STARTING (2007,4) ENDING (2007,6), STARTING (2007,7) ENDING (2007,9), STARTING (2007,10) ENDING (2007,12), STARTING (2008,1) ENDING (2008,3) )
Note that multiple columns are not multiple dimensions. The ranges cannot overlap or else DB2 will raise an error condition:
CREATE TABLE NEIGHBORHOODS (STREET INT, AVENUE INT ) PARTITION BY RANGE(STREET, AVENUE) ( STARTING (1,1) ENDING (10,10), STARTING (1,11) ENDING (10,20) ) ; SQL0636N Range specified for data partition "PART0" is not valid. Reason code = "10". SQLSTATE=56016
The reason for the error is due to the overlapping ranges between the two partition specifications. The first range goes from (1,1) to (10,20) while the second goes from (1,11) to (10,20). While this would appear to be reasonable, the problem is with the way ranges are computed. Ranges are linear so when the second range ends at (1,20), it starts back over at (2,1) instead of (2,11) as one might expect. If the data needs to be organized by grids or cubes the Multidimensional Clustering (MDC) feature should be used instead.
FROM: http://www.toadworld.com/platforms/ibmdb2/w/wiki/7352.partitioning-on-multiple-columns
本文介绍了如何在DB2中使用多个列进行数据分区,并通过示例展示了正确的分区定义方法及可能遇到的范围重叠错误。此外,还提到了当需要按网格或立方体组织数据时应考虑使用多维聚类(MDC)功能。

1845

被折叠的 条评论
为什么被折叠?



