DB2 修改表结构过程

 

    修修改db2表结构:

    1.导出表中的数据

        EXPORT TO '%DATA_PATH%/NEGDBV5.DB2INST1.UKEY_INFO_TAB.65.1/UKEY_INFO_TAB.ixf'
          OF IXF
          SELECT * FROM UKEY_INFO_TAB@

    2.drop表

        DROP TABLE UKEY_INFO_TAB@

    3.创建表

        CREATE TABLE DB2INST1.UKEY_INFO_TAB
             (

            --字段

             )@

 

            注:如果表中有自增字段,还需修改自增字段的下一个值

                    ALTER TABLE DB2INST1.UKEY_INFO_TAB
                          LOCKSIZE ROW
                          APPEND OFF
                           NOT VOLATILE
                          ALTER COLUMN UKEYID
                           RESTART WITH 12000;

    4.倒入数据

        IMPORT FROM '%DATA_PATH%/NEGDBV5.DB2INST1.UKEY_INFO_TAB.65.1/UKEY_INFO_TAB.ixf'
          OF IXF
           MODIFIED BY NOCHECKLENGTHS
           COMMITCOUNT 1000
           INSERT
           INTO DB2INST1.UKEY_INFO_TAB@

        

           注:其中COMMITCOUNT 为多少条记录提交一次

    

    5.修改表的关联关系

        
        ALTER TABLE DB2INST1.UKEY_INFO_TAB
          ADD CONSTRAINT "PK_UKEY_I" PRIMARY KEY
           ("UKEYID"
           );

你可能感兴趣的:(DB2 修改表结构过程)