db2 - Partitioning on Multiple Columns

Posted t0nsha

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了db2 - Partitioning on Multiple Columns相关的知识,希望对你有一定的参考价值。

Partitioning on Multiple Columns

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 - Partitioning on Multiple Columns的主要内容,如果未能解决你的问题,请参考以下文章

atcoder CODE FESTIVAL 2017 qual C D - Yet Another Palindrome Partitioning

DB2 bind on z/os

db2数据库create database on语句是啥意思

DB2——表的append on属性

How to install fixpack on DB2

How to install fixpack on DB2