IBM Support

Ability to create range partitions out of order

News


Abstract

You can now create and add range partitions in any order in a range-partitioned table with a single key, so Generate SQL no longer fails with SQL0636.

Content

You are in: IBM i Technology Updates > Db2 for i - Technology Updates > Db2 for i Database Engineer (DBE) Enhancements > Ability to create range partitions out of order


Before this enhancement, creating a range-partitioned table with CREATE TABLE required the ranges to be in order. When you added partitions, the new partition was always the last partition. When you used Generate SQL against the table, the CREATE TABLE statement failed with SQL0636 because the ranges were not in order.

This enhancement applies to range partitions with a single key. The CREATE TABLE statement now permits unordered range partitions.

Example: Add a partition and then clone the table

create table corpdb.sales_table(trans_date timestamp) 
  partition by range(trans_date)         
    (starting('2013-01-01 00:00:00.000000')
     ending ('2013-03-31 23:59:59.999999'),       
    starting('2013-07-01 00:00:00.000000')
    ending ('2013-09-30 23:59:59.999999'));

-- Oops, forgot a partition, add it in
alter table corpdb.sales_table add partition
   starting('2013-04-01 00:00:00.000000')
   ending ('2013-06-30 23:59:59.999999'); 

To recreate or clone the table later, you can use the Generate SQL feature in IBM i Access Client Solutions to extract the SQL statements. Because range partitions no longer need to be in order, the SQL0636 error is no longer issued, and the table is created.

Figure 1. The SQL0636 error that is no longer issued

image-20200117131651-1

{ "data": [ { "Article Type":"News (DB600)", "Category":"SQL", "ARM Category":"IBM i Db2 > IBM i Technology Updates", "Keywords":"range partitioning; CREATE TABLE; ALTER TABLE ADD PARTITION; SQL0636; Generate SQL; IBM i Access Client Solutions; Db2 for i; unordered partitions; DBE enhancements; database engineer", "Predicate":"USAGE", "Classifier":"DEVELOP" } ] }

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CGJAA2","label":"IBM i Db2-\u003EIBM i Technology Updates"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"6.1.0;7.1.0;7.2.0;7.3.0;7.4.0;7.5.0;7.6.0","Edition":""}]

Document Information

Modified date:
02 December 2026

UID

ibm11168444