从db2分区表中分离并重新附加

时间:2016-07-19 13:58:34

标签: sql db2 partitioning db2-luw

我创建了一个分区表。但我使用了错误的引用语法'MAXVALUE'。这需要MAXVALUE,如下所示。如何解决这个问题?

CREATE TABLE RMOBJECTSPAR  (
                  "OBJ_LIBRARYID" SMALLINT NOT NULL , 
                  "OBJ_ITEMID" CHAR(26 OCTETS) NOT NULL , 
                  "OBJ_VERSION" SMALLINT NOT NULL WITH DEFAULT 1 , 
                  "OBJ_COLLECTIONID" INTEGER NOT NULL , 
                  "OBJ_MGTCLASSID" SMALLINT NOT NULL , 
                  "OBJ_STGCLASSID" SMALLINT NOT NULL , 
                  "OBJ_ATTRIBUTES" SMALLINT NOT NULL WITH DEFAULT 0 , 
                  "OBJ_RETENTION" INTEGER NOT NULL WITH DEFAULT 0 , 
                  "OBJ_VOLUMEID" INTEGER NOT NULL , 
                  "OBJ_STAGEDVOLUMEID" INTEGER NOT NULL WITH DEFAULT -1 , 
                  "OBJ_PATH" INTEGER NOT NULL , 
                  "OBJ_STATUS" CHAR(1 OCTETS) NOT NULL , 
                  "OBJ_SIZE" BIGINT NOT NULL , 
                  "OBJ_CREATEDATE" TIMESTAMP NOT NULL WITH DEFAULT CURRENT TIMESTAMP , 
                  "OBJ_UPDATEDATE" TIMESTAMP NOT NULL WITH DEFAULT CURRENT TIMESTAMP , 
                  "OBJ_REFERENCEDDATE" TIMESTAMP NOT NULL WITH DEFAULT CURRENT TIMESTAMP , 
                  "OBJ_ACTIONDATE" DATE NOT NULL , 
                  "OBJ_MGTCLASSDATE" DATE NOT NULL , 
                  "OBJ_STGCLASSDATE" DATE NOT NULL , 
                  "OBJ_PLAYSTATUS" CHAR(1 OCTETS) NOT NULL , 
                  "OBJ_VOLSTATUS" CHAR(1 OCTETS) NOT NULL , 
                  "OBJ_OBJECTNAME" VARCHAR(128 OCTETS) WITH DEFAULT '' , 
                  "OBJ_ORGFILENAME" VARCHAR(1024 OCTETS) WITH DEFAULT '' , 
                  "OBJ_FILENAME" VARCHAR(128 OCTETS) WITH DEFAULT '' , 
                  "OBJ_MIMETYPE" VARCHAR(128 OCTETS) NOT NULL WITH DEFAULT 'text/html' , 
                  "OBJ_OFFSET" BIGINT NOT NULL WITH DEFAULT -1 , 
                  "OBJ_SIGNATURE" VARCHAR(514 OCTETS) FOR BIT DATA )   
PARTITION BY RANGE(OBJ_ITEMID)
    (
    PARTITION par1 STARTING MINVALUE ENDING 'A1001001A14L31C35959J99999' IN OBJECTS,
    PARTITION par2 STARTING 'A1001001A14A01A00000A00001' ENDING 'A1001001A14L31C35959J99999' IN OBJECTS01,
    PARTITION par3 STARTING 'A1001001A15A01A00000A00001' ENDING 'A1001001A15F31C35959J99999' IN OBJECTS02,
    PARTITION par4 STARTING 'A1001001A16G01A00000A00001' ENDING 'A1001001A16L31C35959J99999' IN OBJECTS03,
    PARTITION par5 STARTING 'A1001001A16G01A00000A00001' ENDING 'A1001001A16L31C35959J99999' IN OBJECTS04,
    PARTITION par6 STARTING 'A1001001A17G01A00000A00001' ENDING 'A1001001A17L31C35959J99999' IN OBJECTS05,
    PARTITION par7 STARTING 'A1001001A18G01A00000A00001' ENDING 'A1001001A18L31C35959J99999' IN OBJECTS06,
    PARTITION par8 STARTING 'A1001001A19G01A00000A00001' ENDING 'A1001001A19L31C35959J99999' IN OBJECTS07,
    PARTITION par9 STARTING 'B0000000000000000000000001' ENDING 'MAXVALUE' IN OBJECTS08
    );

1 个答案:

答案 0 :(得分:2)

抱歉,我们的iSeries系统上没有安装DB2 Multisystem PTF,因此我无法测试SQL语句,但这是我重新连接par9的解决方案:

ALTER TABLE RMOBJECTSPAR DETACH PARTITION par9
INTO dummy;

ALTER TABLE RMOBJECTSPAR ATTACH PARTITION par9
STARTING FROM 'B0000000000000000000000001' ENDING AT MAXVALUE IN OBJECTS08 
FROM dummy;

这可以解决您的问题,但请先测试以确保。

另外,也许可以这样定义你的分区:

PARTITION BY RANGE(OBJ_ITEMID)
    (
    PARTITION par1 STARTING MINVALUE ENDING 'A1001001A14A01A00000A00001' EXCLUSIVE IN OBJECTS,
    PARTITION par2 STARTING 'A1001001A14A01A00000A00001' IN OBJECTS01,
    PARTITION par3 STARTING 'A1001001A15A01A00000A00001' IN OBJECTS02,
    PARTITION par4 STARTING 'A1001001A16G01A00000A00001' IN OBJECTS03,
    PARTITION par5 STARTING 'A1001001A16G01A00000A00001' IN OBJECTS04,
    PARTITION par6 STARTING 'A1001001A17G01A00000A00001' IN OBJECTS05,
    PARTITION par7 STARTING 'A1001001A18G01A00000A00001' IN OBJECTS06,
    PARTITION par8 STARTING 'A1001001A19G01A00000A00001' IN OBJECTS07,
    PARTITION par9 STARTING 'B0000000000000000000000001' ENDING MAXVALUE IN OBJECTS08
    );

我使用过的参考资料:

Adding data partitions to partitioned tables

ALTER TABLE statement