数据库

位置:IT落伍者 >> 数据库 >> 浏览文章

IBM DB2 的数据复制、迁移方法[2]


发布日期:2018年07月10日
 
IBM DB2 的数据复制、迁移方法[2]

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

[] []

               

上一篇:DB2 “Viper 2”助力IT敏捷性[1]

下一篇:IBM DB2 的数据复制、迁移方法[1]