熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> DB2 >> 正文

IBM DB2 的數據復制、遷移方法[2]

2013-11-15 14:31:40  來源: DB2 

    sbappend(enterFlag);

    }

    String str = sbtoString();

    FileUtilitysaveStringToFile(filePath str false);

    }
 
    附錄:生成import腳本代碼示例:/**

    * 創建裝載腳本

    * @param conn

    * @param creator 表創建者

    * @param filePath

    */

    public void createLoadFile(Connection connString creatorString filePath) throws Exception {

    DBBase dbBase = new DBBase(conn);

    String selectTableSql = select name from sysibmsystables where creator = + creator + and type=T;

    try {

    dbBaseexecuteQuery(selectTableSql);

    } catch (Exception ex) {

    throw ex;

    } finally {

    dbBaseclose();

    }

    DBResult result = dbBasegetSelectDBResult();

    List list = new ArrayList();

    while (resultnext()) {

    String table = resultgetString();

    listadd(table);

    }

    StringBuffer sb = new StringBuffer();

    String enterFlag = \r\n;

    for (int i = ; i < listsize();i++) {

    String tableName = (String)listget(i);

    sbappend(db \load from aa + StringvalueOf(i+)+ ixf of ixf into + tableName + COPY NO without prompting \);

    sbappend(enterFlag);

    }

    String str = sbtoString();

    FileUtilitysaveStringToFile(filePath str false);

    }

    附錄:export腳本示例db connect to testdb user test password test

    db export to aaixf of ixf select * from table

    db export to aaixf of ixf select * from table

    db connect reset

    附錄:import腳本示例db connect to testdb user test password test 
    db load from aaixf of ixf replace into table COPY NO without prompting

    db load from aaixf of ixf replace into table COPY NO without prompting

    db connect reset

 

[]  []  


From:http://tw.wingwit.com/Article/program/DB2/201311/21945.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.